summaryrefslogtreecommitdiff
path: root/docs/topics/forms
diff options
context:
space:
mode:
authorClifford Gama <cliffygamy@gmail.com>2025-03-08 15:46:58 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-12 09:16:15 +0100
commit0ebea6e5c07485a36862e9b6e2be18d1694ad2c5 (patch)
tree6ece342336bea4fbdd74cd29a51d9a071901fc82 /docs/topics/forms
parent5183f7c287a9a5d61ca1103b55166cda52d9c647 (diff)
Fixed #35676 -- Made BaseModelForm validate constraints that reference an InlineForeignKeyField.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'docs/topics/forms')
-rw-r--r--docs/topics/forms/modelforms.txt20
1 files changed, 12 insertions, 8 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index e2a37296b7..ef916d882d 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -242,9 +242,13 @@ when calling :meth:`~django.forms.Form.is_valid()` or accessing the
``full_clean()``, although you will typically not use the latter method in
practice.
-``Model`` validation (:meth:`Model.full_clean()
-<django.db.models.Model.full_clean()>`) is triggered from within the form
-validation step, right after the form's ``clean()`` method is called.
+``Model`` validation is triggered from within the form validation step right
+after the form's ``clean()`` method is called. First, the model's
+:meth:`~django.db.models.Model.full_clean()` is called with
+``validate_unique=False`` and ``validate_constraints=False``, then the model's
+:meth:`~django.db.models.Model.validate_unique()` and
+:meth:`~django.db.models.Model.validate_constraints()` methods are called in
+order.
.. warning::
@@ -267,10 +271,10 @@ attribute that gives its methods access to that specific model instance.
.. warning::
- The ``ModelForm.clean()`` method sets a flag that makes the :ref:`model
+ The ``ModelForm.clean()`` method sets flags that make the :ref:`model
validation <validating-objects>` step validate the uniqueness of model
fields that are marked as ``unique``, ``unique_together`` or
- ``unique_for_date|month|year``.
+ ``unique_for_date|month|year``, as well as constraints.
If you would like to override the ``clean()`` method and maintain this
validation, you must call the parent class's ``clean()`` method.
@@ -284,9 +288,9 @@ If you have excluded any model fields, validation will not be run on those
fields. See the :doc:`form validation </ref/forms/validation>` documentation
for more on how field cleaning and validation work.
-The model's ``clean()`` method will be called before any uniqueness checks are
-made. See :ref:`Validating objects <validating-objects>` for more information
-on the model's ``clean()`` hook.
+The model's ``clean()`` method will be called before any uniqueness or
+constraint checks are made. See :ref:`Validating objects <validating-objects>`
+for more information on the model's ``clean()`` hook.
.. _considerations-regarding-model-errormessages: