Ticket #6427: forms.py

File forms.py, 636 bytes (added by Bela Hausmann <post@…>, 8 years ago)

localflavor.at.forms

Line 
1"""
2AT-specific Form helpers
3"""
4
5from django.newforms.fields import RegexField, Select
6from django.utils.translation import ugettext
7
8class ATZipCodeField(RegexField):
9    default_error_messages = {
10        'invalid': ugettext('Enter a zip code in the format XXXX.'),
11    }
12
13    def __init__(self, *args, **kwargs):
14        super(ATZipCodeField, self).__init__(r'^\d{4}$',
15            max_length=None, min_length=None, *args, **kwargs)
16
17class ATProvinceSelect(Select):
18    def __init__(self, attrs=None):
19        from at_provinces import PROVINCE_CHOICES
20        super(ATProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
Back to Top