855 lines
25 KiB
Plaintext
855 lines
25 KiB
Plaintext
==========================
|
|
The "local flavor" add-ons
|
|
==========================
|
|
|
|
.. module:: django.contrib.localflavor
|
|
:synopsis: A collection of various Django snippets that are useful only for
|
|
a particular country or culture.
|
|
|
|
Following its "batteries included" philosophy, Django comes with assorted
|
|
pieces of code that are useful for particular countries or cultures. These are
|
|
called the "local flavor" add-ons and live in the
|
|
:mod:`django.contrib.localflavor` package.
|
|
|
|
Inside that package, country- or culture-specific code is organized into
|
|
subpackages, named using `ISO 3166 country codes`_.
|
|
|
|
Most of the ``localflavor`` add-ons are localized form components deriving
|
|
from the :doc:`forms </topics/forms/index>` framework -- for example, a
|
|
:class:`~django.contrib.localflavor.us.forms.USStateField` that knows how to
|
|
validate U.S. state abbreviations, and a
|
|
:class:`~django.contrib.localflavor.fi.forms.FISocialSecurityNumber` that
|
|
knows how to validate Finnish social security numbers.
|
|
|
|
To use one of these localized components, just import the relevant subpackage.
|
|
For example, here's how you can create a form with a field representing a
|
|
French telephone number::
|
|
|
|
from django import forms
|
|
from django.contrib.localflavor.fr.forms import FRPhoneNumberField
|
|
|
|
class MyForm(forms.Form):
|
|
my_french_phone_no = FRPhoneNumberField()
|
|
|
|
Supported countries
|
|
===================
|
|
|
|
Countries currently supported by :mod:`~django.contrib.localflavor` are:
|
|
|
|
* Argentina_
|
|
* Australia_
|
|
* Austria_
|
|
* Belgium_
|
|
* Brazil_
|
|
* Canada_
|
|
* Chile_
|
|
* Czech_
|
|
* Finland_
|
|
* France_
|
|
* Germany_
|
|
* Iceland_
|
|
* India_
|
|
* Indonesia_
|
|
* Ireland_
|
|
* Italy_
|
|
* Japan_
|
|
* Kuwait_
|
|
* Mexico_
|
|
* `The Netherlands`_
|
|
* Norway_
|
|
* Peru_
|
|
* Poland_
|
|
* Portugal_
|
|
* Romania_
|
|
* Slovakia_
|
|
* `South Africa`_
|
|
* Spain_
|
|
* Sweden_
|
|
* Switzerland_
|
|
* `United Kingdom`_
|
|
* `United States of America`_
|
|
* Uruguay_
|
|
|
|
The ``django.contrib.localflavor`` package also includes a ``generic`` subpackage,
|
|
containing useful code that is not specific to one particular country or culture.
|
|
Currently, it defines date, datetime and split datetime input fields based on
|
|
those from :doc:`forms </topics/forms/index>`, but with non-US default formats.
|
|
Here's an example of how to use them::
|
|
|
|
from django import forms
|
|
from django.contrib.localflavor import generic
|
|
|
|
class MyForm(forms.Form):
|
|
my_date_field = generic.forms.DateField()
|
|
|
|
.. _ISO 3166 country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
|
|
.. _Argentina: `Argentina (ar)`_
|
|
.. _Australia: `Australia (au)`_
|
|
.. _Austria: `Austria (at)`_
|
|
.. _Belgium: `Belgium (be)`_
|
|
.. _Brazil: `Brazil (br)`_
|
|
.. _Canada: `Canada (ca)`_
|
|
.. _Chile: `Chile (cl)`_
|
|
.. _Czech: `Czech (cz)`_
|
|
.. _Finland: `Finland (fi)`_
|
|
.. _France: `France (fr)`_
|
|
.. _Germany: `Germany (de)`_
|
|
.. _The Netherlands: `The Netherlands (nl)`_
|
|
.. _Iceland: `Iceland (is\_)`_
|
|
.. _India: `India (in\_)`_
|
|
.. _Indonesia: `Indonesia (id)`_
|
|
.. _Ireland: `Ireland (ie)`_
|
|
.. _Italy: `Italy (it)`_
|
|
.. _Japan: `Japan (jp)`_
|
|
.. _Kuwait: `Kuwait (kw)`_
|
|
.. _Mexico: `Mexico (mx)`_
|
|
.. _Norway: `Norway (no)`_
|
|
.. _Peru: `Peru (pe)`_
|
|
.. _Poland: `Poland (pl)`_
|
|
.. _Portugal: `Portugal (pt)`_
|
|
.. _Romania: `Romania (ro)`_
|
|
.. _Slovakia: `Slovakia (sk)`_
|
|
.. _South Africa: `South Africa (za)`_
|
|
.. _Spain: `Spain (es)`_
|
|
.. _Sweden: `Sweden (se)`_
|
|
.. _Switzerland: `Switzerland (ch)`_
|
|
.. _United Kingdom: `United Kingdom (uk)`_
|
|
.. _United States of America: `United States of America (us)`_
|
|
.. _Uruguay: `Uruguay (uy)`_
|
|
|
|
Adding flavors
|
|
==============
|
|
|
|
We'd love to add more of these to Django, so please `create a ticket`_ with
|
|
any code you'd like to contribute. One thing we ask is that you please use
|
|
Unicode objects (``u'mystring'``) for strings, rather than setting the encoding
|
|
in the file. See any of the existing flavors for examples.
|
|
|
|
.. _create a ticket: http://code.djangoproject.com/simpleticket
|
|
|
|
Argentina (``ar``)
|
|
=============================================
|
|
|
|
.. class:: ar.forms.ARPostalCodeField
|
|
|
|
A form field that validates input as either a classic four-digit Argentinian
|
|
postal code or a CPA_.
|
|
|
|
.. _CPA: http://www.correoargentino.com.ar/consulta_cpa/home.php
|
|
|
|
.. class:: ar.forms.ARDNIField
|
|
|
|
A form field that validates input as a Documento Nacional de Identidad (DNI)
|
|
number.
|
|
|
|
.. class:: ar.forms.ARCUITField
|
|
|
|
A form field that validates input as a Codigo Unico de Identificacion
|
|
Tributaria (CUIT) number.
|
|
|
|
.. class:: ar.forms.ARProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Argentina's provinces and autonomous
|
|
cities as its choices.
|
|
|
|
Australia (``au``)
|
|
=============================================
|
|
|
|
.. class:: au.forms.AUPostCodeField
|
|
|
|
A form field that validates input as an Australian postcode.
|
|
|
|
.. class:: au.forms.AUPhoneNumberField
|
|
|
|
A form field that validates input as an Australian phone number. Valid numbers
|
|
have ten digits.
|
|
|
|
.. class:: au.forms.AUStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Australian states/territories as its
|
|
choices.
|
|
|
|
Austria (``at``)
|
|
================
|
|
|
|
.. class:: at.forms.ATZipCodeField
|
|
|
|
A form field that validates its input as an Austrian zip code.
|
|
|
|
.. class:: at.forms.ATStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Austrian states as its choices.
|
|
|
|
.. class:: at.forms.ATSocialSecurityNumberField
|
|
|
|
A form field that validates its input as an Austrian social security number.
|
|
|
|
Belgium (``be``)
|
|
================
|
|
|
|
.. versionadded:: 1.3
|
|
|
|
.. class:: be.forms.BEPhoneNumberField
|
|
|
|
A form field that validates input as a Belgium phone number, with one of
|
|
the formats 0x xxx xx xx, 0xx xx xx xx, 04xx xx xx xx, 0x/xxx.xx.xx,
|
|
0xx/xx.xx.xx, 04xx/xx.xx.xx, 0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx,
|
|
0xxxxxxxx or 04xxxxxxxx.
|
|
|
|
.. class:: be.forms.BEPostalCodeField
|
|
|
|
A form field that validates input as a Belgium postal code, in the range
|
|
and format 1XXX-9XXX.
|
|
|
|
.. class:: be.forms.BEProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Belgium provinces as its
|
|
choices.
|
|
|
|
.. class:: be.forms.BERegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Belgium regions as its
|
|
choices.
|
|
|
|
Brazil (``br``)
|
|
===============
|
|
|
|
.. class:: br.forms.BRPhoneNumberField
|
|
|
|
A form field that validates input as a Brazilian phone number, with the format
|
|
XX-XXXX-XXXX.
|
|
|
|
.. class:: br.forms.BRZipCodeField
|
|
|
|
A form field that validates input as a Brazilian zip code, with the format
|
|
XXXXX-XXX.
|
|
|
|
.. class:: br.forms.BRStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Brazilian states/territories as its
|
|
choices.
|
|
|
|
Canada (``ca``)
|
|
===============
|
|
|
|
.. class:: ca.forms.CAPhoneNumberField
|
|
|
|
A form field that validates input as a Canadian phone number, with the format
|
|
XXX-XXX-XXXX.
|
|
|
|
.. class:: ca.forms.CAPostalCodeField
|
|
|
|
A form field that validates input as a Canadian postal code, with the format
|
|
XXX XXX.
|
|
|
|
.. class:: ca.forms.CAProvinceField
|
|
|
|
A form field that validates input as a Canadian province name or abbreviation.
|
|
|
|
.. class:: ca.forms.CASocialInsuranceNumberField
|
|
|
|
A form field that validates input as a Canadian Social Insurance Number (SIN).
|
|
A valid number must have the format XXX-XXX-XXX and pass a `Luhn mod-10
|
|
checksum`_.
|
|
|
|
.. _Luhn mod-10 checksum: http://en.wikipedia.org/wiki/Luhn_algorithm
|
|
|
|
.. class:: ca.forms.CAProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Canadian provinces and territories as
|
|
its choices.
|
|
|
|
Chile (``cl``)
|
|
==============
|
|
|
|
.. class:: cl.forms.CLRutField
|
|
|
|
A form field that validates input as a Chilean national identification number
|
|
('Rol Unico Tributario' or RUT). The valid format is XX.XXX.XXX-X.
|
|
|
|
.. class:: cl.forms.CLRegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Chilean regions (Regiones) as its
|
|
choices.
|
|
|
|
Czech (``cz``)
|
|
==============
|
|
|
|
.. class:: cz.forms.CZPostalCodeField
|
|
|
|
A form field that validates input as a Czech postal code. Valid formats
|
|
are XXXXX or XXX XX, where X is a digit.
|
|
|
|
.. class:: cz.forms.CZBirthNumberField
|
|
|
|
A form field that validates input as a Czech Birth Number.
|
|
A valid number must be in format XXXXXX/XXXX (slash is optional).
|
|
|
|
.. class:: cz.forms.CZICNumberField
|
|
|
|
A form field that validates input as a Czech IC number field.
|
|
|
|
.. class:: cz.forms.CZRegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Czech regions as its choices.
|
|
|
|
Finland (``fi``)
|
|
================
|
|
|
|
.. class:: fi.forms.FISocialSecurityNumber
|
|
|
|
A form field that validates input as a Finnish social security number.
|
|
|
|
.. class:: fi.forms.FIZipCodeField
|
|
|
|
A form field that validates input as a Finnish zip code. Valid codes
|
|
consist of five digits.
|
|
|
|
.. class:: fi.forms.FIMunicipalitySelect
|
|
|
|
A ``Select`` widget that uses a list of Finnish municipalities as its
|
|
choices.
|
|
|
|
France (``fr``)
|
|
===============
|
|
|
|
.. class:: fr.forms.FRPhoneNumberField
|
|
|
|
A form field that validates input as a French local phone number. The
|
|
correct format is 0X XX XX XX XX. 0X.XX.XX.XX.XX and 0XXXXXXXXX validate
|
|
but are corrected to 0X XX XX XX XX.
|
|
|
|
.. class:: fr.forms.FRZipCodeField
|
|
|
|
A form field that validates input as a French zip code. Valid codes
|
|
consist of five digits.
|
|
|
|
.. class:: fr.forms.FRDepartmentSelect
|
|
|
|
A ``Select`` widget that uses a list of French departments as its choices.
|
|
|
|
Germany (``de``)
|
|
================
|
|
|
|
.. class:: de.forms.DEIdentityCardNumberField
|
|
|
|
A form field that validates input as a German identity card number
|
|
(Personalausweis_). Valid numbers have the format
|
|
XXXXXXXXXXX-XXXXXXX-XXXXXXX-X, with no group consisting entirely of zeroes.
|
|
|
|
.. _Personalausweis: http://de.wikipedia.org/wiki/Personalausweis
|
|
|
|
.. class:: de.forms.DEZipCodeField
|
|
|
|
A form field that validates input as a German zip code. Valid codes
|
|
consist of five digits.
|
|
|
|
.. class:: de.forms.DEStateSelect
|
|
|
|
A ``Select`` widget that uses a list of German states as its choices.
|
|
|
|
The Netherlands (``nl``)
|
|
========================
|
|
|
|
.. class:: nl.forms.NLPhoneNumberField
|
|
|
|
A form field that validates input as a Dutch telephone number.
|
|
|
|
.. class:: nl.forms.NLSofiNumberField
|
|
|
|
A form field that validates input as a Dutch social security number
|
|
(SoFI/BSN).
|
|
|
|
.. class:: nl.forms.NLZipCodeField
|
|
|
|
A form field that validates input as a Dutch zip code.
|
|
|
|
.. class:: nl.forms.NLProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Dutch provinces as its list of
|
|
choices.
|
|
|
|
Iceland (``is_``)
|
|
=================
|
|
|
|
.. class:: is_.forms.ISIdNumberField
|
|
|
|
A form field that validates input as an Icelandic identification number
|
|
(kennitala). The format is XXXXXX-XXXX.
|
|
|
|
.. class:: is_.forms.ISPhoneNumberField
|
|
|
|
A form field that validates input as an Icelandtic phone number (seven
|
|
digits with an optional hyphen or space after the first three digits).
|
|
|
|
.. class:: is_.forms.ISPostalCodeSelect
|
|
|
|
A ``Select`` widget that uses a list of Icelandic postal codes as its
|
|
choices.
|
|
|
|
India (``in_``)
|
|
===============
|
|
|
|
.. class:: in.forms.INStateField
|
|
|
|
A form field that validates input as an Indian state/territory name or
|
|
abbreviation. Input is normalized to the standard two-letter vehicle
|
|
registration abbreviation for the given state or territory.
|
|
|
|
.. class:: in.forms.INZipCodeField
|
|
|
|
A form field that validates input as an Indian zip code, with the
|
|
format XXXXXXX.
|
|
|
|
.. class:: in.forms.INStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Indian states/territories as its
|
|
choices.
|
|
|
|
Ireland (``ie``)
|
|
================
|
|
|
|
.. class:: ie.forms.IECountySelect
|
|
|
|
A ``Select`` widget that uses a list of Irish Counties as its choices.
|
|
|
|
Indonesia (``id``)
|
|
==================
|
|
|
|
.. class:: id.forms.IDPostCodeField
|
|
|
|
A form field that validates input as an Indonesian post code field.
|
|
|
|
.. class:: id.forms.IDProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Indonesian provinces as its choices.
|
|
|
|
.. class:: id.forms.IDPhoneNumberField
|
|
|
|
A form field that validates input as an Indonesian telephone number.
|
|
|
|
.. class:: id.forms.IDLicensePlatePrefixSelect
|
|
|
|
A ``Select`` widget that uses a list of Indonesian license plate
|
|
prefix code as its choices.
|
|
|
|
.. class:: id.forms.IDLicensePlateField
|
|
|
|
A form field that validates input as an Indonesian vehicle license plate.
|
|
|
|
.. class:: id.forms.IDNationalIdentityNumberField
|
|
|
|
A form field that validates input as an Indonesian national identity
|
|
number (`NIK`_/KTP). The output will be in the format of
|
|
'XX.XXXX.DDMMYY.XXXX'. Dots or spaces can be used in the input to break
|
|
down the numbers.
|
|
|
|
.. _NIK: http://en.wikipedia.org/wiki/Indonesian_identity_card
|
|
|
|
Italy (``it``)
|
|
==============
|
|
|
|
.. class:: it.forms.ITSocialSecurityNumberField
|
|
|
|
A form field that validates input as an Italian social security number
|
|
(`codice fiscale`_).
|
|
|
|
.. _codice fiscale: http://www.agenziaentrate.it/ilwwcm/connect/Nsi/Servizi/Codice+fiscale+-+tessera+sanitaria/NSI+Informazioni+sulla+codificazione+delle+persone+fisiche
|
|
|
|
.. class:: it.forms.ITVatNumberField
|
|
|
|
A form field that validates Italian VAT numbers (partita IVA).
|
|
|
|
.. class:: it.forms.ITZipCodeField
|
|
|
|
A form field that validates input as an Italian zip code. Valid codes
|
|
must have five digits.
|
|
|
|
.. class:: it.forms.ITProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Italian provinces as its choices.
|
|
|
|
.. class:: it.forms.ITRegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Italian regions as its choices.
|
|
|
|
Japan (``jp``)
|
|
==============
|
|
|
|
.. class:: jp.forms.JPPostalCodeField
|
|
|
|
A form field that validates input as a Japanese postcode. It accepts seven
|
|
digits, with or without a hyphen.
|
|
|
|
.. class:: jp.forms.JPPrefectureSelect
|
|
|
|
A ``Select`` widget that uses a list of Japanese prefectures as its choices.
|
|
|
|
Kuwait (``kw``)
|
|
===============
|
|
|
|
.. class:: kw.forms.KWCivilIDNumberField
|
|
|
|
A form field that validates input as a Kuwaiti Civil ID number. A valid
|
|
Civil ID number must obey the following rules:
|
|
|
|
* The number consist of 12 digits.
|
|
* The birthdate of the person is a valid date.
|
|
* The calculated checksum equals to the last digit of the Civil ID.
|
|
|
|
Mexico (``mx``)
|
|
===============
|
|
|
|
.. class:: mx.forms.MXStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Mexican states as its choices.
|
|
|
|
Norway (``no``)
|
|
===============
|
|
|
|
.. class:: no.forms.NOSocialSecurityNumber
|
|
|
|
A form field that validates input as a Norwegian social security number
|
|
(personnummer_).
|
|
|
|
.. _personnummer: http://no.wikipedia.org/wiki/Personnummer
|
|
|
|
.. class:: no.forms.NOZipCodeField
|
|
|
|
A form field that validates input as a Norwegian zip code. Valid codes
|
|
have four digits.
|
|
|
|
.. class:: no.forms.NOMunicipalitySelect
|
|
|
|
A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
|
|
its choices.
|
|
|
|
Peru (``pe``)
|
|
=============
|
|
|
|
.. class:: pe.forms.PEDNIField
|
|
|
|
A form field that validates input as a DNI (Peruvian national identity)
|
|
number.
|
|
|
|
.. class:: pe.forms.PERUCField
|
|
|
|
A form field that validates input as an RUC (Registro Unico de
|
|
Contribuyentes) number. Valid RUC numbers have 11 digits.
|
|
|
|
.. class:: pe.forms.PEDepartmentSelect
|
|
|
|
A ``Select`` widget that uses a list of Peruvian Departments as its choices.
|
|
|
|
Poland (``pl``)
|
|
===============
|
|
|
|
.. class:: pl.forms.PLPESELField
|
|
|
|
A form field that validates input as a Polish national identification number
|
|
(PESEL_).
|
|
|
|
.. _PESEL: http://en.wikipedia.org/wiki/PESEL
|
|
|
|
.. class:: pl.forms.PLREGONField
|
|
|
|
A form field that validates input as a Polish National Official Business
|
|
Register Number (REGON_), having either seven or nine digits. The checksum
|
|
algorithm used for REGONs is documented at
|
|
http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
|
|
|
|
.. _REGON: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
|
|
|
|
.. class:: pl.forms.PLPostalCodeField
|
|
|
|
A form field that validates input as a Polish postal code. The valid format
|
|
is XX-XXX, where X is a digit.
|
|
|
|
.. class:: pl.forms.PLNIPField
|
|
|
|
A form field that validates input as a Polish Tax Number (NIP). Valid
|
|
formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX. The checksum algorithm used
|
|
for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
|
|
|
|
.. class:: pl.forms.PLCountySelect
|
|
|
|
A ``Select`` widget that uses a list of Polish administrative units as its
|
|
choices.
|
|
|
|
.. class:: pl.forms.PLProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Polish voivodeships (administrative
|
|
provinces) as its choices.
|
|
|
|
Portugal (``pt``)
|
|
=================
|
|
|
|
.. class:: pt.forms.PTZipCodeField
|
|
|
|
A form field that validates input as a Portuguese zip code.
|
|
|
|
.. class:: pt.forms.PTPhoneNumberField
|
|
|
|
A form field that validates input as a Portuguese phone number.
|
|
Valid numbers have 9 digits (may include spaces) or start by 00
|
|
or + (international).
|
|
|
|
Romania (``ro``)
|
|
================
|
|
|
|
.. class:: ro.forms.ROCIFField
|
|
|
|
A form field that validates Romanian fiscal identification codes (CIF). The
|
|
return value strips the leading RO, if given.
|
|
|
|
.. class:: ro.forms.ROCNPField
|
|
|
|
A form field that validates Romanian personal numeric codes (CNP).
|
|
|
|
.. class:: ro.forms.ROCountyField
|
|
|
|
A form field that validates its input as a Romanian county (judet) name or
|
|
abbreviation. It normalizes the input to the standard vehicle registration
|
|
abbreviation for the given county. This field will only accept names written
|
|
with diacritics; consider using ROCountySelect as an alternative.
|
|
|
|
.. class:: ro.forms.ROCountySelect
|
|
|
|
A ``Select`` widget that uses a list of Romanian counties (judete) as its
|
|
choices.
|
|
|
|
.. class:: ro.forms.ROIBANField
|
|
|
|
A form field that validates its input as a Romanian International Bank
|
|
Account Number (IBAN). The valid format is ROXX-XXXX-XXXX-XXXX-XXXX-XXXX,
|
|
with or without hyphens.
|
|
|
|
.. class:: ro.forms.ROPhoneNumberField
|
|
|
|
A form field that validates Romanian phone numbers, short special numbers
|
|
excluded.
|
|
|
|
.. class:: ro.forms.ROPostalCodeField
|
|
|
|
A form field that validates Romanian postal codes.
|
|
|
|
Slovakia (``sk``)
|
|
=================
|
|
|
|
.. class:: sk.forms.SKPostalCodeField
|
|
|
|
A form field that validates input as a Slovak postal code. Valid formats
|
|
are XXXXX or XXX XX, where X is a digit.
|
|
|
|
.. class:: sk.forms.SKDistrictSelect
|
|
|
|
A ``Select`` widget that uses a list of Slovak districts as its choices.
|
|
|
|
.. class:: sk.forms.SKRegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Slovak regions as its choices.
|
|
|
|
South Africa (``za``)
|
|
=====================
|
|
|
|
.. class:: za.forms.ZAIDField
|
|
|
|
A form field that validates input as a South African ID number. Validation
|
|
uses the Luhn checksum and a simplistic (i.e., not entirely accurate) check
|
|
for birth date.
|
|
|
|
.. class:: za.forms.ZAPostCodeField
|
|
|
|
A form field that validates input as a South African postcode. Valid
|
|
postcodes must have four digits.
|
|
|
|
Spain (``es``)
|
|
==============
|
|
|
|
.. class:: es.forms.ESIdentityCardNumberField
|
|
|
|
A form field that validates input as a Spanish NIF/NIE/CIF (Fiscal
|
|
Identification Number) code.
|
|
|
|
.. class:: es.forms.ESCCCField
|
|
|
|
A form field that validates input as a Spanish bank account number (Codigo
|
|
Cuenta Cliente or CCC). A valid CCC number has the format
|
|
EEEE-OOOO-CC-AAAAAAAAAA, where the E, O, C and A digits denote the entity,
|
|
office, checksum and account, respectively. The first checksum digit
|
|
validates the entity and office. The second checksum digit validates the
|
|
account. It is also valid to use a space as a delimiter, or to use no
|
|
delimiter.
|
|
|
|
.. class:: es.forms.ESPhoneNumberField
|
|
|
|
A form field that validates input as a Spanish phone number. Valid numbers
|
|
have nine digits, the first of which is 6, 8 or 9.
|
|
|
|
.. class:: es.forms.ESPostalCodeField
|
|
|
|
A form field that validates input as a Spanish postal code. Valid codes
|
|
have five digits, the first two being in the range 01 to 52, representing
|
|
the province.
|
|
|
|
.. class:: es.forms.ESProvinceSelect
|
|
|
|
A ``Select`` widget that uses a list of Spanish provinces as its choices.
|
|
|
|
.. class:: es.forms.ESRegionSelect
|
|
|
|
A ``Select`` widget that uses a list of Spanish regions as its choices.
|
|
|
|
Sweden (``se``)
|
|
===============
|
|
|
|
.. class:: se.forms.SECountySelect
|
|
|
|
A Select form widget that uses a list of the Swedish counties (län) as its
|
|
choices.
|
|
|
|
The cleaned value is the official county code -- see
|
|
http://en.wikipedia.org/wiki/Counties_of_Sweden for a list.
|
|
|
|
.. class:: se.forms.SEOrganisationNumber
|
|
|
|
A form field that validates input as a Swedish organisation number
|
|
(organisationsnummer).
|
|
|
|
It accepts the same input as SEPersonalIdentityField (for sole
|
|
proprietorships (enskild firma). However, co-ordination numbers are not
|
|
accepted.
|
|
|
|
It also accepts ordinary Swedish organisation numbers with the format
|
|
NNNNNNNNNN.
|
|
|
|
The return value will be YYYYMMDDXXXX for sole proprietors, and NNNNNNNNNN
|
|
for other organisations.
|
|
|
|
.. class:: se.forms.SEPersonalIdentityNumber
|
|
|
|
A form field that validates input as a Swedish personal identity number
|
|
(personnummer).
|
|
|
|
The correct formats are YYYYMMDD-XXXX, YYYYMMDDXXXX, YYMMDD-XXXX,
|
|
YYMMDDXXXX and YYMMDD+XXXX.
|
|
|
|
A \+ indicates that the person is older than 100 years, which will be taken
|
|
into consideration when the date is validated.
|
|
|
|
The checksum will be calculated and checked. The birth date is checked
|
|
to be a valid date.
|
|
|
|
By default, co-ordination numbers (samordningsnummer) will be accepted. To
|
|
only allow real personal identity numbers, pass the keyword argument
|
|
coordination_number=False to the constructor.
|
|
|
|
The cleaned value will always have the format YYYYMMDDXXXX.
|
|
|
|
.. class:: se.forms.SEPostalCodeField
|
|
|
|
A form field that validates input as a Swedish postal code (postnummer).
|
|
Valid codes consist of five digits (XXXXX). The number can optionally be
|
|
formatted with a space after the third digit (XXX XX).
|
|
|
|
The cleaned value will never contain the space.
|
|
|
|
Switzerland (``ch``)
|
|
====================
|
|
|
|
.. class:: ch.forms.CHIdentityCardNumberField
|
|
|
|
A form field that validates input as a Swiss identity card number.
|
|
A valid number must confirm to the X1234567<0 or 1234567890 format and
|
|
have the correct checksums -- see http://adi.kousz.ch/artikel/IDCHE.htm.
|
|
|
|
.. class:: ch.forms.CHPhoneNumberField
|
|
|
|
A form field that validates input as a Swiss phone number. The correct
|
|
format is 0XX XXX XX XX. 0XX.XXX.XX.XX and 0XXXXXXXXX validate but are
|
|
corrected to 0XX XXX XX XX.
|
|
|
|
.. class:: ch.forms.CHZipCodeField
|
|
|
|
A form field that validates input as a Swiss zip code. Valid codes
|
|
consist of four digits.
|
|
|
|
.. class:: ch.forms.CHStateSelect
|
|
|
|
A ``Select`` widget that uses a list of Swiss states as its choices.
|
|
|
|
United Kingdom (``uk``)
|
|
=======================
|
|
|
|
.. class:: uk.forms.UKPostcodeField
|
|
|
|
A form field that validates input as a UK postcode. The regular
|
|
expression used is sourced from the schema for British Standard BS7666
|
|
address types at http://www.cabinetoffice.gov.uk/media/291293/bs7666-v2-0.xml.
|
|
|
|
.. class:: uk.forms.UKCountySelect
|
|
|
|
A ``Select`` widget that uses a list of UK counties/regions as its choices.
|
|
|
|
.. class:: uk.forms.UKNationSelect
|
|
|
|
A ``Select`` widget that uses a list of UK nations as its choices.
|
|
|
|
United States of America (``us``)
|
|
=================================
|
|
|
|
.. class:: us.forms.USPhoneNumberField
|
|
|
|
A form field that validates input as a U.S. phone number.
|
|
|
|
.. class:: us.forms.USSocialSecurityNumberField
|
|
|
|
A form field that validates input as a U.S. Social Security Number (SSN).
|
|
A valid SSN must obey the following rules:
|
|
|
|
* Format of XXX-XX-XXXX
|
|
* No group of digits consisting entirely of zeroes
|
|
* Leading group of digits cannot be 666
|
|
* Number not in promotional block 987-65-4320 through 987-65-4329
|
|
* Number not one known to be invalid due to widespread promotional
|
|
use or distribution (e.g., the Woolworth's number or the 1962
|
|
promotional number)
|
|
|
|
.. class:: us.forms.USStateField
|
|
|
|
A form field that validates input as a U.S. state name or abbreviation. It
|
|
normalizes the input to the standard two-letter postal service abbreviation
|
|
for the given state.
|
|
|
|
.. class:: us.forms.USZipCodeField
|
|
|
|
A form field that validates input as a U.S. ZIP code. Valid formats are
|
|
XXXXX or XXXXX-XXXX.
|
|
|
|
.. class:: us.forms.USStateSelect
|
|
|
|
A form ``Select`` widget that uses a list of U.S. states/territories as its
|
|
choices.
|
|
|
|
.. class:: us.models.PhoneNumberField
|
|
|
|
A :class:`CharField` that checks that the value is a valid U.S.A.-style phone
|
|
number (in the format ``XXX-XXX-XXXX``).
|
|
|
|
.. class:: us.models.USStateField
|
|
|
|
A model field that forms represent as a ``forms.USStateField`` field and
|
|
stores the two-letter U.S. state abbreviation in the database.
|
|
|
|
Uruguay (``uy``)
|
|
================
|
|
|
|
.. class:: uy.forms.UYCIField
|
|
|
|
A field that validates Uruguayan 'Cedula de identidad' (CI) numbers.
|
|
|
|
.. class:: uy.forms.UYDepartamentSelect
|
|
|
|
A ``Select`` widget that uses a list of Uruguayan departaments as its
|
|
choices.
|