Revert change to the default Form.clean()
This means it doesn't break for people who are doing `cleaned_data = super(FooForm, self).clean()`.
This commit is contained in:
parent
fb1dd6b13a
commit
1c4a9bd9ad
|
@ -318,7 +318,7 @@ class BaseForm(object):
|
||||||
not be associated with a particular field; it will have a special-case
|
not be associated with a particular field; it will have a special-case
|
||||||
association with the field named '__all__'.
|
association with the field named '__all__'.
|
||||||
"""
|
"""
|
||||||
pass
|
return self.cleaned_data
|
||||||
|
|
||||||
def has_changed(self):
|
def has_changed(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -129,8 +129,7 @@ Minor features
|
||||||
|
|
||||||
* The :meth:`~django.forms.Form.clean` method on a form no longer needs to
|
* 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
|
return ``self.cleaned_data``. If it does return a changed dictionary then
|
||||||
that will still be used. The default implementation no longer returns
|
that will still be used.
|
||||||
``self.cleaned_data``.
|
|
||||||
|
|
||||||
Backwards incompatible changes in 1.7
|
Backwards incompatible changes in 1.7
|
||||||
=====================================
|
=====================================
|
||||||
|
|
|
@ -620,6 +620,19 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
|
||||||
self.assertTrue(f.is_valid())
|
self.assertTrue(f.is_valid())
|
||||||
self.assertEqual(f.cleaned_data['username'], 'sirrobin')
|
self.assertEqual(f.cleaned_data['username'], 'sirrobin')
|
||||||
|
|
||||||
|
def test_changing_cleaned_data_nothing_returned(self):
|
||||||
|
class UserForm(Form):
|
||||||
|
username = CharField(max_length=10)
|
||||||
|
password = CharField(widget=PasswordInput)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
self.cleaned_data['username'] = self.cleaned_data['username'].lower()
|
||||||
|
# don't return anything
|
||||||
|
|
||||||
|
f = UserForm({'username': 'SirRobin', 'password': 'blue'})
|
||||||
|
self.assertTrue(f.is_valid())
|
||||||
|
self.assertEqual(f.cleaned_data['username'], 'sirrobin')
|
||||||
|
|
||||||
def test_changing_cleaned_data_in_clean(self):
|
def test_changing_cleaned_data_in_clean(self):
|
||||||
class UserForm(Form):
|
class UserForm(Form):
|
||||||
username = CharField(max_length=10)
|
username = CharField(max_length=10)
|
||||||
|
|
Loading…
Reference in New Issue