Canada (ca)¶
Forms¶
Canada-specific Form helpers
-
class
localflavor.ca.forms.CAPhoneNumberField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)[source]¶ Canadian phone number form field.
-
class
localflavor.ca.forms.CAPostalCodeField(max_length=None, min_length=None, *args, **kwargs)[source]¶ Canadian postal code form field.
Validates against known invalid characters: D, F, I, O, Q, U Additionally the first character cannot be Z or W. For more info see: http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp#1402170
-
class
localflavor.ca.forms.CAProvinceField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)[source]¶ A form field that validates its input is a Canadian province name or abbreviation. It normalizes the input to the standard two-leter postal service abbreviation for the given province.
-
class
localflavor.ca.forms.CAProvinceSelect(attrs=None)[source]¶ A Select widget that uses a list of Canadian provinces and territories as its choices.
-
class
localflavor.ca.forms.CASocialInsuranceNumberField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)[source]¶ A Canadian Social Insurance Number (SIN).
Checks the following rules to determine whether the number is valid:
Conforms to the XXX-XXX-XXX format.
- Passes the check digit process “Luhn Algorithm”
Data¶
-
localflavor.ca.ca_provinces.PROVINCE_CHOICES= (('AB', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc5d0>), ('BC', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc610>), ('MB', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc650>), ('NB', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc690>), ('NL', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc910>), ('NT', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc810>), ('NS', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc890>), ('NU', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc9d0>), ('ON', <django.utils.functional.__proxy__ object at 0x7f1e9dfbca50>), ('PE', <django.utils.functional.__proxy__ object at 0x7f1e9dfbcd10>), ('QC', <django.utils.functional.__proxy__ object at 0x7f1e9dfbcc10>), ('SK', <django.utils.functional.__proxy__ object at 0x7f1e9dfbcc90>), ('YT', <django.utils.functional.__proxy__ object at 0x7f1e9dfbc190>))¶ An alphabetical list of provinces and territories for use as choices in a formfield. Source: http://www.canada.gc.ca/othergov/prov_e.html
-
localflavor.ca.ca_provinces.PROVINCES_NORMALIZED= {'yk': 'YT', 'ab': 'AB', 'bc': 'BC', 'pq': 'QC', 'ontario': 'ON', 'prince edward island': 'PE', 'p.e.i.': 'PE', 'british columbia': 'BC', 'nova scotia': 'NS', 'quebec': 'QC', 'saskatchewan': 'SK', 'manitoba': 'MB', 'b.c.': 'BC', 'new brunswick': 'NB', 'nunavut': 'NU', 'yukon': 'YT', 'on': 'ON', 'ns': 'NS', 'nl': 'NL', 'newfoundland and labrador': 'NL', 'mb': 'MB', 'nb': 'NB', 'nf': 'NL', 'nu': 'NU', 'sk': 'SK', 'qc': 'QC', 'yukon territory': 'YT', 'pei': 'PE', 'pe': 'PE', 'alberta': 'AB', 'northwest territories': 'NT', 'nt': 'NT', 'newfoundland': 'NL', 'yt': 'YT'}¶ a mapping of province misspellings/abbreviations to normalized abbreviations