Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 9aa6d4bdb6618ba4f17acc7b7c0d1462d6cbc718 1 parent 8ed9646
Baptiste Mispelon authored November 12, 2013

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
@@ -78,6 +78,10 @@ overridden:
78 78
   like. This method can return a completely different dictionary if it wishes,
79 79
   which will be used as the ``cleaned_data``.
80 80
 
  81
+  Since the field validation method have been run by the time ``clean()`` is
  82
+  called, you also have access to the form's ``errors`` attribute which
  83
+  contains all the errors raised by previous steps.
  84
+
81 85
   Note that any errors raised by your ``Form.clean()`` override will not
82 86
   be associated with any field in particular. They go into a special
83 87
   "field" (called ``__all__``), which you can access via the
@@ -95,7 +99,8 @@ These methods are run in the order given above, one field at a time.  That is,
95 99
 for each field in the form (in the order they are declared in the form
96 100
 definition), the ``Field.clean()`` method (or its override) is run, then
97 101
 ``clean_<fieldname>()``. Finally, once those two methods are run for every
98  
-field, the ``Form.clean()`` method, or its override, is executed.
  102
+field, the ``Form.clean()`` method, or its override, is executed, no matter if
  103
+the previous methods have raised errors or not.
99 104
 
100 105
 Examples of each of these methods are provided below.
101 106
 
@@ -104,15 +109,6 @@ field, if the ``Field.clean()`` method raises a ``ValidationError``, any
104 109
 field-specific cleaning method is not called. However, the cleaning methods
105 110
 for all remaining fields are still executed.
106 111
 
107  
-The ``clean()`` method for the ``Form`` class or subclass is always run. If
108  
-that method raises a ``ValidationError``, ``cleaned_data`` will be an empty
109  
-dictionary.
110  
-
111  
-The previous paragraph means that if you are overriding ``Form.clean()``, you
112  
-should iterate through ``self.cleaned_data.items()``, possibly considering the
113  
-``_errors`` dictionary attribute on the form as well. In this way, you will
114  
-already know which fields have passed their individual validation requirements.
115  
-
116 112
 .. _raising-validation-error:
117 113
 
118 114
 Raising ``ValidationError``

0 notes on commit 9aa6d4b

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