summaryrefslogtreecommitdiff
path: root/django/forms/forms.py
diff options
context:
space:
mode:
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):
"""