summaryrefslogtreecommitdiff
path: root/django/forms/fields.py
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-06-18 00:31:57 +0000
committerHonza Král <honza.kral@gmail.com>2009-06-18 00:31:57 +0000
commitae581816befd992b9e7e667d124f427d849bcfd0 (patch)
treee75e957dfcdc74e4db1cfc76f6dfe8c66eea78f4 /django/forms/fields.py
parentd707d370482e0ac80db74025b7ae1c7dac9a1b45 (diff)
[soc2009/model-validation] Added code param to ValidationError and use it to override validator's messages
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11035 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/fields.py')
-rw-r--r--django/forms/fields.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 882887f3e0..ee0b387b95 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -131,7 +131,10 @@ class Field(object):
try:
v(value)
except ValidationError, e:
- errors.extend(e.messages)
+ if hasattr(e, 'code'):
+ errors.append(self.error_messages.get(e.code, e.messages[0]))
+ else:
+ errors.extend(e.messages)
if errors:
raise ValidationError(errors)