mirror of
https://github.com/django/django.git
synced 2025-07-07 03:09:22 +00:00
[soc2009/model-validation] have complex validators also use error_messages if applicable
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11036 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ae581816be
commit
d06bca726d
@ -261,7 +261,11 @@ class BaseForm(StrAndUnicode):
|
||||
try:
|
||||
v(self.cleaned_data[name], all_values=self.cleaned_data)
|
||||
except ValidationError, e:
|
||||
self._errors.setdefault(name, self.error_class()).extend(e.messages)
|
||||
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]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user