Fixed #12017 - Overriding the default error message of the UKPostcodeField works again.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12044 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6eb205c914
commit
4b2e674329
|
@ -33,7 +33,7 @@ class UKPostcodeField(CharField):
|
|||
# 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):
|
||||
|
|
|
@ -58,4 +58,15 @@ u'BT32 4PX'
|
|||
u''
|
||||
>>> f.clean('')
|
||||
u''
|
||||
>>> class MyUKPostcodeField(UKPostcodeField):
|
||||
... default_error_messages = {
|
||||
... 'invalid': 'Enter a bloody postcode!',
|
||||
... }
|
||||
...
|
||||
>>>
|
||||
>>> f = MyUKPostcodeField(required=False)
|
||||
>>> f.clean('1NV 4L1D')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a bloody postcode!']
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue