Skip to content
Browse files

[1.1.X] Fixed #12017 - Overriding the default error message of the UK…

…PostcodeField works again. Backport of r12044 and r12249.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent abea4e6 commit d1e7fdea3fe3e4dd28301151ef4e83fe2a2d0a1c @jezdez jezdez committed Jan 17, 2010
Showing with 6 additions and 1 deletion.
  1. +1 −1 django/contrib/localflavor/uk/forms.py
  2. +5 −0 tests/regressiontests/forms/localflavor/uk.py
View
2 django/contrib/localflavor/uk/forms.py
@@ -33,7 +33,7 @@ def clean(self, value):
# Put a single space before the incode (second part).
postcode = self.space_regex.sub(r' \1', postcode)
if not self.postcode_regex.search(postcode):
- raise ValidationError(self.default_error_messages['invalid'])
+ raise ValidationError(self.error_messages['invalid'])
return postcode
class UKCountySelect(Select):
View
5 tests/regressiontests/forms/localflavor/uk.py
@@ -58,4 +58,9 @@
u''
>>> f.clean('')
u''
+>>> f = UKPostcodeField(error_messages={'invalid': 'Enter a bloody postcode!'})
+>>> f.clean('1NV 4L1D')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a bloody postcode!']
"""

0 comments on commit d1e7fde

Please sign in to comment.
Something went wrong with that request. Please try again.