diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-05-24 10:02:53 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-05-24 10:03:19 +0200 |
| commit | 3d4bab28de16c56e7fcd94a26a570f5bc730e691 (patch) | |
| tree | 1fc4c0f5411a73b1f52b9c490a65a836cf842e25 /docs/ref | |
| parent | 9fc56af0fbd77253bd8e90b8478e32b0d30fc6b9 (diff) | |
[4.1.x] Fixed #33724 -- Doc'd exclude argument changes in model validation.
Thanks אורי for the report.
Follow up to 1ea7e3157d1f9b4db71e768d75ea57e47dbd49f9.
Backport of 90aabd730a2a434c227faf8a927b0e2ccd67e291 from main
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/instances.txt | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 9aa9486f4a..71fb880740 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -224,8 +224,8 @@ This method calls :meth:`Model.clean_fields()`, :meth:`Model.clean()`, in that order and raises a :exc:`~django.core.exceptions.ValidationError` that has a ``message_dict`` attribute containing errors from all four stages. -The optional ``exclude`` argument can be used to provide a list of field names -that can be excluded from validation and cleaning. +The optional ``exclude`` argument can be used to provide a ``set`` of field +names that can be excluded from validation and cleaning. :class:`~django.forms.ModelForm` uses this argument to exclude fields that aren't present on your form from being validated since any errors raised could not be corrected by the user. @@ -249,12 +249,16 @@ The first step ``full_clean()`` performs is to clean each individual field. The ``validate_constraints`` argument was added. +.. versionchanged:: 4.1 + + An ``exclude`` value is now converted to a ``set`` rather than a ``list``. + .. method:: Model.clean_fields(exclude=None) This method will validate all fields on your model. The optional ``exclude`` -argument lets you provide a list of field names to exclude from validation. It -will raise a :exc:`~django.core.exceptions.ValidationError` if any fields fail -validation. +argument lets you provide a ``set`` of field names to exclude from validation. +It will raise a :exc:`~django.core.exceptions.ValidationError` if any fields +fail validation. The second step ``full_clean()`` performs is to call :meth:`Model.clean()`. This method should be overridden to perform custom validation on your model. @@ -355,8 +359,8 @@ uniqueness constraints defined via :attr:`.Field.unique`, :attr:`.Field.unique_for_date`, :attr:`.Field.unique_for_month`, :attr:`.Field.unique_for_year`, or :attr:`Meta.unique_together <django.db.models.Options.unique_together>` on your model instead of individual -field values. The optional ``exclude`` argument allows you to provide a list of -field names to exclude from validation. It will raise a +field values. The optional ``exclude`` argument allows you to provide a ``set`` +of field names to exclude from validation. It will raise a :exc:`~django.core.exceptions.ValidationError` if any fields fail validation. :class:`~django.db.models.UniqueConstraint`\s defined in the @@ -380,7 +384,7 @@ Finally, ``full_clean()`` will check any other constraints on your model. This method validates all constraints defined in :attr:`Meta.constraints <django.db.models.Options.constraints>`. The -optional ``exclude`` argument allows you to provide a list of field names to +optional ``exclude`` argument allows you to provide a ``set`` of field names to exclude from validation. It will raise a :exc:`~django.core.exceptions.ValidationError` if any constraints fail validation. |
