Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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...
commit d1e7fdea3fe3e4dd28301151ef4e83fe2a2d0a1c 1 parent abea4e6
Jannis Leidel authored January 17, 2010
2  django/contrib/localflavor/uk/forms.py
@@ -33,7 +33,7 @@ def clean(self, value):
33 33
         # Put a single space before the incode (second part).
34 34
         postcode = self.space_regex.sub(r' \1', postcode)
35 35
         if not self.postcode_regex.search(postcode):
36  
-            raise ValidationError(self.default_error_messages['invalid'])
  36
+            raise ValidationError(self.error_messages['invalid'])
37 37
         return postcode
38 38
 
39 39
 class UKCountySelect(Select):
5  tests/regressiontests/forms/localflavor/uk.py
@@ -58,4 +58,9 @@
58 58
 u''
59 59
 >>> f.clean('')
60 60
 u''
  61
+>>> f = UKPostcodeField(error_messages={'invalid': 'Enter a bloody postcode!'})
  62
+>>> f.clean('1NV 4L1D')
  63
+Traceback (most recent call last):
  64
+...
  65
+ValidationError: [u'Enter a bloody postcode!']
61 66
 """

0 notes on commit d1e7fde

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