Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12017 - Overriding the default error message of the UKPostcode…

…Field works again.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12044 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4b2e6743290de5170b2ac96b46241046947f4510 1 parent 6eb205c
Jannis Leidel authored January 01, 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):
11  tests/regressiontests/forms/localflavor/uk.py
@@ -58,4 +58,15 @@
58 58
 u''
59 59
 >>> f.clean('')
60 60
 u''
  61
+>>> class MyUKPostcodeField(UKPostcodeField):
  62
+...    default_error_messages = {
  63
+...        'invalid': 'Enter a bloody postcode!',
  64
+...    }
  65
+...
  66
+>>>
  67
+>>> f = MyUKPostcodeField(required=False)
  68
+>>> f.clean('1NV 4L1D')
  69
+Traceback (most recent call last):
  70
+...
  71
+ValidationError: [u'Enter a bloody postcode!']
61 72
 """

0 notes on commit 4b2e674

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