Canada (ca)

Forms

Canada-specific Form helpers

class localflavor.ca.forms.CAPhoneNumberField(required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=[], localize=False, disabled=False, label_suffix=None)[source]

Canadian phone number form field.

class localflavor.ca.forms.CAPostalCodeField(max_length=None, min_length=None, strip=True, *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='', 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='', 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:

Data

localflavor.ca.ca_provinces.PROVINCE_CHOICES = (('AB', 'Alberta'), ('BC', 'British Columbia'), ('MB', 'Manitoba'), ('NB', 'New Brunswick'), ('NL', 'Newfoundland and Labrador'), ('NT', 'Northwest Territories'), ('NS', 'Nova Scotia'), ('NU', 'Nunavut'), ('ON', 'Ontario'), ('PE', 'Prince Edward Island'), ('QC', 'Quebec'), ('SK', 'Saskatchewan'), ('YT', '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 = {'qc': 'QC', 'newfoundland': 'NL', 'british columbia': 'BC', 'nb': 'NB', 'nunavut': 'NU', 'pq': 'QC', 'nu': 'NU', 'ab': 'AB', 'saskatchewan': 'SK', 'yukon territory': 'YT', 'newfoundland and labrador': 'NL', 'prince edward island': 'PE', 'on': 'ON', 'ns': 'NS', 'pe': 'PE', 'nf': 'NL', 'alberta': 'AB', 'nova scotia': 'NS', 'bc': 'BC', 'p.e.i.': 'PE', 'ontario': 'ON', 'yt': 'YT', 'yk': 'YT', 'nt': 'NT', 'northwest territories': 'NT', 'b.c.': 'BC', 'mb': 'MB', 'yukon': 'YT', 'manitoba': 'MB', 'nl': 'NL', 'sk': 'SK', 'new brunswick': 'NB', 'pei': 'PE', 'quebec': 'QC'}

a mapping of province misspellings/abbreviations to normalized abbreviations