summaryrefslogtreecommitdiff
path: root/django/forms/forms.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-01-21 02:28:03 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-01-21 02:28:03 +0000
commit408d4310291cd1287f3dbc05aaeb5d205eba8751 (patch)
tree88788fcaa4c5fc3f33aacd66ef0c8a0adc7375cc /django/forms/forms.py
parent856a39e841080abc34e8ae3bb2b20f780c33762d (diff)
Fixed #12596. Calling super from a ModelForm's clean method is once again optional. Failing to call super only skips unique validation as documented. Thanks for the initial patch and tests, carljm.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12269 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/forms.py')
-rw-r--r--django/forms/forms.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index c53a901e73..6f7a8ce97d 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -263,6 +263,12 @@ class BaseForm(StrAndUnicode):
# changed from the initial data, short circuit any validation.
if self.empty_permitted and not self.has_changed():
return
+ self._clean_fields()
+ self._clean_form()
+ if self._errors:
+ delattr(self, 'cleaned_data')
+
+ def _clean_fields(self):
for name, field in self.fields.items():
# value_from_datadict() gets the data from the data dictionaries.
# Each widget type knows how to retrieve its own data, because some
@@ -282,12 +288,12 @@ class BaseForm(StrAndUnicode):
self._errors[name] = self.error_class(e.messages)
if name in self.cleaned_data:
del self.cleaned_data[name]
+
+ def _clean_form(self):
try:
self.cleaned_data = self.clean()
except ValidationError, e:
self._errors[NON_FIELD_ERRORS] = self.error_class(e.messages)
- if self._errors:
- delattr(self, 'cleaned_data')
def clean(self):
"""