Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert change to the default Form.clean()

This means it doesn't break for people who are doing
`cleaned_data = super(FooForm, self).clean()`.
  • Loading branch information...
commit 1c4a9bd9ad1a8e61817c6aa2b0d8d0ad2c080047 1 parent fb1dd6b
Marc Tamlyn authored August 08, 2013
2  django/forms/forms.py
@@ -318,7 +318,7 @@ def clean(self):
318 318
         not be associated with a particular field; it will have a special-case
319 319
         association with the field named '__all__'.
320 320
         """
321  
-        pass
  321
+        return self.cleaned_data
322 322
 
323 323
     def has_changed(self):
324 324
         """
3  docs/releases/1.7.txt
@@ -129,8 +129,7 @@ Minor features
129 129
 
130 130
 * The :meth:`~django.forms.Form.clean` method on a form no longer needs to
131 131
   return ``self.cleaned_data``. If it does return a changed dictionary then
132  
-  that will still be used. The default implementation no longer returns
133  
-  ``self.cleaned_data``.
  132
+  that will still be used.
134 133
 
135 134
 Backwards incompatible changes in 1.7
136 135
 =====================================
13  tests/forms_tests/tests/test_extra.py
@@ -620,6 +620,19 @@ def clean(self):
620 620
         self.assertTrue(f.is_valid())
621 621
         self.assertEqual(f.cleaned_data['username'], 'sirrobin')
622 622
 
  623
+    def test_changing_cleaned_data_nothing_returned(self):
  624
+        class UserForm(Form):
  625
+            username = CharField(max_length=10)
  626
+            password = CharField(widget=PasswordInput)
  627
+
  628
+            def clean(self):
  629
+                self.cleaned_data['username'] = self.cleaned_data['username'].lower()
  630
+                # don't return anything
  631
+
  632
+        f = UserForm({'username': 'SirRobin', 'password': 'blue'})
  633
+        self.assertTrue(f.is_valid())
  634
+        self.assertEqual(f.cleaned_data['username'], 'sirrobin')
  635
+
623 636
     def test_changing_cleaned_data_in_clean(self):
624 637
         class UserForm(Form):
625 638
             username = CharField(max_length=10)

0 notes on commit 1c4a9bd

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