summaryrefslogtreecommitdiff
path: root/django/forms/forms.py
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-07-05 13:26:57 +0000
committerHonza Král <honza.kral@gmail.com>2009-07-05 13:26:57 +0000
commit63f244f14413e0981c76dda8bf6f76e7b9df3d2a (patch)
tree658bece75d870d28a333ae5f8e3f59f3a7b1ea73 /django/forms/forms.py
parent8424c8ae6cb817a978783ffed479c9959ef9c668 (diff)
[soc2009/model-validation] Make sure that all validators in the same group (simple/complex) get run even if they all fail and we get all their messages.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11185 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/forms.py')
-rw-r--r--django/forms/forms.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index bb5b086d05..c7f07657d4 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -254,6 +254,7 @@ class BaseForm(StrAndUnicode):
for name, field in self.fields.items():
if not name in self.cleaned_data:
continue
+ failed = False
for v in field.validators:
# skip noncomplex validators, they have already been run on the Field
if not isinstance(v, ComplexValidator):
@@ -261,14 +262,14 @@ class BaseForm(StrAndUnicode):
try:
v(self.cleaned_data[name], all_values=self.cleaned_data)
except ValidationError, e:
+ failed = True
error_list = self._errors.setdefault(name, self.error_class())
if hasattr(e, 'code'):
error_list.append(field.error_messages.get(e.code, e.messages[0]))
else:
error_list.extend(e.messages)
- if name in self.cleaned_data:
- del self.cleaned_data[name]
-
+ if failed:
+ del self.cleaned_data[name]
try:
self.cleaned_data = self.clean()
except ValidationError, e: