1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #12960. The return value of ModelForm.clean() is now applied to the model. Thanks for the report, krejcik.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12690 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2010-03-06 18:42:56 +00:00
parent a2c4ad1dab
commit b88f969789
3 changed files with 45 additions and 16 deletions

View File

@@ -72,6 +72,26 @@ class OverrideCleanTests(TestCase):
# by form.full_clean().
self.assertEquals(form.instance.left, 1)
# Regression test for #12960.
# Make sure the cleaned_data returned from ModelForm.clean() is applied to the
# model instance.
class PublicationForm(forms.ModelForm):
def clean(self):
print self.cleaned_data
self.cleaned_data['title'] = self.cleaned_data['title'].upper()
return self.cleaned_data
class Meta:
model = Publication
class ModelFormCleanTest(TestCase):
def test_model_form_clean_applies_to_model(self):
data = {'title': 'test', 'date_published': '2010-2-25'}
form = PublicationForm(data)
publication = form.save()
self.assertEqual(publication.title, 'TEST')
class FPForm(forms.ModelForm):
class Meta:
model = FilePathModel