summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2013-08-08 14:05:55 +0100
committerMarc Tamlyn <marc.tamlyn@gmail.com>2013-08-08 14:05:55 +0100
commitfb1dd6b13a0e6b1ef64eac88467321d097942cd2 (patch)
tree7dfdd7b3f7a5cb2f63c5046cedfb90fa4884163c /docs
parent7a2296eb5bb05a4109392f8333e934d576d79d35 (diff)
Form.clean() does not need to return cleaned_data.
If it does, that will be used as the cleaned_data. The default implementation has been changed to match this change.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/validation.txt12
-rw-r--r--docs/releases/1.7.txt5
2 files changed, 7 insertions, 10 deletions
diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
index 87f9741c1b..c6d2722bf7 100644
--- a/docs/ref/forms/validation.txt
+++ b/docs/ref/forms/validation.txt
@@ -75,10 +75,8 @@ overridden:
any validation that requires access to multiple fields from the form at
once. This is where you might put in things to check that if field ``A``
is supplied, field ``B`` must contain a valid email address and the
- like. The data that this method returns is the final ``cleaned_data``
- attribute for the form, so don't forget to return the full list of
- cleaned data if you override this method (by default, ``Form.clean()``
- just returns ``self.cleaned_data``).
+ like. This method can return a completely different dictionary if it wishes,
+ which will be used as the ``cleaned_data``.
Note that any errors raised by your ``Form.clean()`` override will not
be associated with any field in particular. They go into a special
@@ -403,9 +401,6 @@ example::
raise forms.ValidationError("Did not send for 'help' in "
"the subject despite CC'ing yourself.")
- # Always return the full collection of cleaned data.
- return cleaned_data
-
In this code, if the validation error is raised, the form will display an
error message at the top of the form (normally) describing the problem.
@@ -443,9 +438,6 @@ sample) looks like this::
del cleaned_data["cc_myself"]
del cleaned_data["subject"]
- # Always return the full collection of cleaned data.
- return cleaned_data
-
As you can see, this approach requires a bit more effort, not withstanding the
extra design effort to create a sensible form display. The details are worth
noting, however. Firstly, earlier we mentioned that you might need to check if
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index fbbf93f627..6bf13834d2 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -127,6 +127,11 @@ Minor features
for each individual field will be respected, and a new ``incomplete``
validation error will be raised when any required fields are empty.
+* The :meth:`~django.forms.Form.clean` method on a form no longer needs to
+ return ``self.cleaned_data``. If it does return a changed dictionary then
+ that will still be used. The default implementation no longer returns
+ ``self.cleaned_data``.
+
Backwards incompatible changes in 1.7
=====================================