Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.6.x] Removed a mention of `Form._errors` from the documentation.

Also removed a sentence that was incorrect: raising a
`ValidationError` inside `Form.clean` doesn't clear the
`cleaned_data` attribute.

Thanks to loic84 and timograham for the review.

Backport of 9aa6d4b and
0048ed7 from master.
  • Loading branch information...
commit b6acc4f7498f195096e20af3e4fe0dd68d2dbac8 1 parent 4aed1ee
Baptiste Mispelon authored

Showing 1 changed file with 6 additions and 10 deletions. Show diff stats Hide diff stats

  1. 16  docs/ref/forms/validation.txt
16  docs/ref/forms/validation.txt
@@ -80,6 +80,10 @@ overridden:
80 80
   cleaned data if you override this method (by default, ``Form.clean()``
81 81
   just returns ``self.cleaned_data``).
82 82
+  Since the field validation methods have been run by the time ``clean()`` is
+  called, you also have access to the form's errors attribute which
+  contains all the errors raised by cleaning of individual fields.
83 87
   Note that any errors raised by your ``Form.clean()`` override will not
84 88
   be associated with any field in particular. They go into a special
85 89
   "field" (called ``__all__``), which you can access via the
@@ -97,7 +101,8 @@ These methods are run in the order given above, one field at a time.  That is,
97 101
 for each field in the form (in the order they are declared in the form
98 102
 definition), the ``Field.clean()`` method (or its override) is run, then
99 103
 ``clean_<fieldname>()``. Finally, once those two methods are run for every
-field, the ``Form.clean()`` method, or its override, is executed.
+field, the ``Form.clean()`` method, or its override, is executed whether or not
+the previous methods have raised errors.
101 106
102 107
 Examples of each of these methods are provided below.
103 108
@@ -106,15 +111,6 @@ field, if the ``Field.clean()`` method raises a ``ValidationError``, any
106 111
 field-specific cleaning method is not called. However, the cleaning methods
107 112
 for all remaining fields are still executed.
108 113
-The ``clean()`` method for the ``Form`` class or subclass is always run. If
-that method raises a ``ValidationError``, ``cleaned_data`` will be an empty
-The previous paragraph means that if you are overriding ``Form.clean()``, you
-should iterate through ``self.cleaned_data.items()``, possibly considering the
-``_errors`` dictionary attribute on the form as well. In this way, you will
-already know which fields have passed their individual validation requirements.
118 114
 .. _raising-validation-error:
119 115
120 116
 Raising ``ValidationError``

0 notes on commit b6acc4f

Please sign in to comment.
Something went wrong with that request. Please try again.