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, disabled=False, label_suffix=None)[source]¶ Canadian phone number form field.
Deprecated since version 1.4: Use the django-phonenumber-field library instead.
-
class
localflavor.ca.forms.
CAPostalCodeField
(*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, disabled=False, label_suffix=None)[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, disabled=False, label_suffix=None)[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”
- See: http://en.wikipedia.org/wiki/Social_Insurance_Number
Data¶
-
localflavor.ca.ca_provinces.
PROVINCE_CHOICES
= (('AB', u'Alberta'), ('BC', u'British Columbia'), ('MB', u'Manitoba'), ('NB', u'New Brunswick'), ('NL', u'Newfoundland and Labrador'), ('NT', u'Northwest Territories'), ('NS', u'Nova Scotia'), ('NU', u'Nunavut'), ('ON', u'Ontario'), ('PE', u'Prince Edward Island'), ('QC', u'Quebec'), ('SK', u'Saskatchewan'), ('YT', u'Yukon'))¶ 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
= {'yukon territory': 'YT', 'pei': 'PE', 'newfoundland': 'NL', 'bc': 'BC', 'newfoundland and labrador': 'NL', 'manitoba': 'MB', 'pe': 'PE', 'northwest territories': 'NT', 'new brunswick': 'NB', 'on': 'ON', 'mb': 'MB', 'pq': 'QC', 'p.e.i.': 'PE', 'ontario': 'ON', 'nova scotia': 'NS', 'nunavut': 'NU', 'b.c.': 'BC', 'yukon': 'YT', 'ab': 'AB', 'yt': 'YT', 'sk': 'SK', 'ns': 'NS', 'nu': 'NU', 'nt': 'NT', 'quebec': 'QC', 'alberta': 'AB', 'qc': 'QC', 'nb': 'NB', 'british columbia': 'BC', 'nf': 'NL', 'saskatchewan': 'SK', 'prince edward island': 'PE', 'nl': 'NL', 'yk': 'YT'}¶ a mapping of province misspellings/abbreviations to normalized abbreviations