diff options
| author | Honza Král <honza.kral@gmail.com> | 2009-06-18 00:58:39 +0000 |
|---|---|---|
| committer | Honza Král <honza.kral@gmail.com> | 2009-06-18 00:58:39 +0000 |
| commit | d06bca726d765678cd0046070787ab0ed6f04245 (patch) | |
| tree | 7952b907006fe9279847e4e30ae53d9363e710bc | |
| parent | ae581816befd992b9e7e667d124f427d849bcfd0 (diff) | |
[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
| -rw-r--r-- | django/forms/forms.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index 912fd7c031..bb5b086d05 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -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] |
