diff options
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 20 |
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: |
