Fixed #8234: Corrected typo in docs/cache.txt
[django.git] / docs / localflavor.txt
blob71e353c5d8e76c069a5bea8a9b1249ec8c21c2e1
1 ==========================
2 The "local flavor" add-ons
3 ==========================
5 Following its "batteries included" philosophy, Django comes with assorted
6 pieces of code that are useful for particular countries or cultures. These are
7 called the "local flavor" add-ons and live in the ``django.contrib.localflavor``
8 package.
10 Inside that package, country- or culture-specific code is organized into
11 subpackages, named using `ISO 3166 country codes`_.
13 Most of the ``localflavor`` add-ons are localized form components deriving from
14 the forms_ framework -- for example, a ``USStateField`` that knows how to
15 validate U.S. state abbreviations, and a ``FISocialSecurityNumber`` that knows
16 how to validate Finnish social security numbers.
18 To use one of these localized components, just import the relevant subpackage.
19 For example, here's how you can create a form with a field representing a
20 French telephone number::
22     from django import forms
23     from django.contrib.localflavor import fr
25     class MyForm(forms.Form):
26         my_french_phone_no = fr.forms.FRPhoneNumberField()
28 Supported countries
29 ===================
31 Countries currently supported by ``localflavor`` are:
33     * Argentina_
34     * Australia_
35     * Austria_
36     * Brazil_
37     * Canada_
38     * Chile_
39     * Finland_
40     * France_
41     * Germany_
42     * Holland_
43     * Iceland_
44     * India_
45     * Italy_
46     * Japan_
47     * Mexico_
48     * Norway_
49     * Peru_
50     * Poland_
51     * Romania_
52     * Slovakia_
53     * `South Africa`_
54     * Spain_
55     * Switzerland_
56     * `United Kingdom`_
57     * `United States of America`_
59 The ``localflavor`` package also includes a ``generic`` subpackage, containing
60 useful code that is not specific to one particular country or culture.
61 Currently, it defines date and datetime input fields based on those from
62 forms_, but with non-US default formats. Here's an example of how to use
63 them::
65     from django import forms
66     from django.contrib.localflavor import generic
68     class MyForm(forms.Form):
69         my_date_field = generic.forms.DateField()
71 .. _ISO 3166 country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
72 .. _Argentina: `Argentina (django.contrib.localflavor.ar)`_
73 .. _Australia: `Australia (django.contrib.localflavor.au)`_
74 .. _Austria: `Austria (django.contrib.localflavor.at)`_
75 .. _Brazil: `Brazil (django.contrib.localflavor.br)`_
76 .. _Canada: `Canada (django.contrib.localflavor.ca)`_
77 .. _Chile: `Chile (django.contrib.localflavor.cl)`_
78 .. _Finland: `Finland (django.contrib.localflavor.fi)`_
79 .. _France: `France (django.contrib.localflavor.fr)`_
80 .. _Germany: `Germany (django.contrib.localflavor.de)`_
81 .. _Holland: `Holland (django.contrib.localflavor.nl)`_
82 .. _Iceland: `Iceland (django.contrib.localflavor.is\_)`_
83 .. _India: `India (django.contrib.localflavor.in\_)`_
84 .. _Italy: `Italy (django.contrib.localflavor.it)`_
85 .. _Japan: `Japan (django.contrib.localflavor.jp)`_
86 .. _Mexico: `Mexico (django.contrib.localflavor.mx)`_
87 .. _Norway: `Norway (django.contrib.localflavor.no)`_
88 .. _Peru: `Peru (django.contrib.localflavor.pe)`_
89 .. _Poland: `Poland (django.contrib.localflavor.pl)`_
90 .. _Romania: `Romania (django.contrib.localflavor.ro)`_
91 .. _Slovakia: `Slovakia (django.contrib.localflavor.sk)`_
92 .. _South Africa: `South Africa (django.contrib.localflavor.za)`_
93 .. _Spain: `Spain (django.contrib.localflavor.es)`_
94 .. _Switzerland: `Switzerland (django.contrib.localflavor.ch)`_
95 .. _United Kingdom: `United Kingdom (django.contrib.localflavor.uk)`_
96 .. _United States of America: `United States of America (django.contrib.localflavor.us)`_
97 .. _forms: ../forms/
99 Adding flavors
100 ==============
102 We'd love to add more of these to Django, so please `create a ticket`_ with
103 any code you'd like to contribute. One thing we ask is that you please use
104 Unicode objects (``u'mystring'``) for strings, rather than setting the encoding
105 in the file. See any of the existing flavors for examples.
107 .. _create a ticket: http://code.djangoproject.com/simpleticket
109 Argentina (``django.contrib.localflavor.ar``)
110 =============================================
112 ARPostalCodeField
113 -----------------
115 A form field that validates input as either a classic four-digit Argentinian
116 postal code or a CPA_.
118 .. _CPA: http://www.correoargentino.com.ar/consulta_cpa/home.php
120 ARDNIField
121 ----------
123 A form field that validates input as a Documento Nacional de Identidad (DNI)
124 number.
126 ARCUITField
127 -----------
129 A form field that validates input as a Código Único de Identificación
130 Tributaria (CUIT) number.
132 ARProvinceSelect
133 ----------------
135 A ``Select`` widget that uses a list of Argentina's provinces and autonomous
136 cities as its choices.
138 Australia (``django.contrib.localflavor.au``)
139 =============================================
141 AUPostCodeField
142 ---------------
144 A form field that validates input as an Australian postcode.
146 AUPhoneNumberField
147 ------------------
149 A form field that validates input as an Australian phone number. Valid numbers
150 have ten digits.
152 AUStateSelect
153 -------------
155 A ``Select`` widget that uses a list of Australian states/territories as its
156 choices.
158 Austria (``django.contrib.localflavor.at``)
159 =============================================
161 ATZipCodeField
162 ---------------
164 A form field that validates its input as an Austrian zip code.
166 ATStateSelect
167 -------------
169 A ``Select`` widget that uses a list of Austrian states as its choices. 
171 ATSocialSecurityNumberField
172 ---------------------------
174 A form field that validates its input as an Austrian social security number.
176 Brazil (``django.contrib.localflavor.br``)
177 ==========================================
179 BRPhoneNumberField
180 ------------------
182 A form field that validates input as a Brazilian phone number, with the format
183 XX-XXXX-XXXX.
185 BRZipCodeField
186 --------------
188 A form field that validates input as a Brazilian zip code, with the format
189 XXXXX-XXX.
191 BRStateSelect
192 -------------
194 A ``Select`` widget that uses a list of Brazilian states/territories as its
195 choices.
197 Canada (``django.contrib.localflavor.ca``)
198 ==========================================
200 CAPhoneNumberField
201 ------------------
203 A form field that validates input as a Canadian phone number, with the format
204 XXX-XXX-XXXX.
206 CAPostalCodeField
207 -----------------
209 A form field that validates input as a Canadian postal code, with the format
210 XXX XXX.
212 CAProvinceField
213 ---------------
215 A form field that validates input as a Canadian province name or abbreviation.
217 CASocialInsuranceNumberField
218 ----------------------------
220 A form field that validates input as a Canadian Social Insurance Number (SIN).
221 A valid number must have the format XXX-XXX-XXX and pass a `Luhn mod-10
222 checksum`_.
224 .. _Luhn mod-10 checksum: http://en.wikipedia.org/wiki/Luhn_algorithm
226 CAProvinceSelect
227 ----------------
229 A ``Select`` widget that uses a list of Canadian provinces and territories as
230 its choices.
232 Chile (``django.contrib.localflavor.cl``)
233 =========================================
235 CLRutField
236 ----------
238 A form field that validates input as a Chilean national identification number
239 ('Rol Unico Tributario' or RUT). The valid format is XX.XXX.XXX-X.
241 CLRegionSelect
242 --------------
244 A ``Select`` widget that uses a list of Chilean regions (Regiones) as its
245 choices.
247 Finland (``django.contrib.localflavor.fi``)
248 ===========================================
250 FISocialSecurityNumber
251 ----------------------
253 A form field that validates input as a Finnish social security number.
255 FIZipCodeField
256 --------------
258 A form field that validates input as a Finnish zip code. Valid codes
259 consist of five digits.
261 FIMunicipalitySelect
262 --------------------
264 A ``Select`` widget that uses a list of Finnish municipalities as its
265 choices.
267 France (``django.contrib.localflavor.fr``)
268 ==========================================
270 FRPhoneNumberField
271 ------------------
273 A form field that validates input as a French local phone number. The
274 correct format is 0X XX XX XX XX. 0X.XX.XX.XX.XX and 0XXXXXXXXX validate
275 but are corrected to 0X XX XX XX XX.
277 FRZipCodeField
278 --------------
280 A form field that validates input as a French zip code. Valid codes
281 consist of five digits.
283 FRDepartmentSelect
284 ------------------
286 A ``Select`` widget that uses a list of French departments as its choices.
288 Germany (``django.contrib.localflavor.de``)
289 ===========================================
291 DEIdentityCardNumberField
292 -------------------------
294 A form field that validates input as a German identity card number
295 (Personalausweis_). Valid numbers have the format
296 XXXXXXXXXXX-XXXXXXX-XXXXXXX-X, with no group consisting entirely of zeroes.
298 .. _Personalausweis: http://de.wikipedia.org/wiki/Personalausweis
300 DEZipCodeField
301 --------------
303 A form field that validates input as a German zip code. Valid codes
304 consist of five digits.
306 DEStateSelect
307 -------------
309 A ``Select`` widget that uses a list of German states as its choices.
311 Holland (``django.contrib.localflavor.nl``)
312 ===========================================
314 NLPhoneNumberField
315 ------------------
317 A form field that validates input as a Dutch telephone number.
319 NLSofiNumberField
320 -----------------
322 A form field that validates input as a Dutch social security number
323 (SoFI/BSN).
325 NLZipCodeField
326 --------------
328 A form field that validates input as a Dutch zip code.
330 NLProvinceSelect
331 ----------------
333 A ``Select`` widget that uses a list of Dutch provinces as its list of
334 choices.
336 Iceland (``django.contrib.localflavor.is_``)
337 ============================================
339 ISIdNumberField
340 ---------------
342 A form field that validates input as an Icelandic identification number
343 (kennitala). The format is XXXXXX-XXXX.
345 ISPhoneNumberField
346 ------------------
348 A form field that validates input as an Icelandtic phone number (seven
349 digits with an optional hyphen or space after the first three digits).
351 ISPostalCodeSelect
352 ------------------
354 A ``Select`` widget that uses a list of Icelandic postal codes as its
355 choices.
357 India (``django.contrib.localflavor.in_``)
358 ==========================================
360 INStateField
361 ------------
363 A form field that validates input as an Indian state/territory name or
364 abbreviation. Input is normalized to the standard two-letter vehicle
365 registration abbreviation for the given state or territory.
367 INZipCodeField
368 --------------
370 A form field that validates input as an Indian zip code, with the
371 format XXXXXXX.
373 INStateSelect
374 -------------
376 A ``Select`` widget that uses a list of Indian states/territories as its
377 choices.
379 Italy (``django.contrib.localflavor.it``)
380 =========================================
382 ITSocialSecurityNumberField
383 ---------------------------
385 A form field that validates input as an Italian social security number
386 (`codice fiscale`_).
388 .. _codice fiscale: http://www.agenziaentrate.it/ilwwcm/connect/Nsi/Servizi/Codice+fiscale+-+tessera+sanitaria/Codice+fiscale/NSI+Informazioni+sulla+codificazione+delle+persone+fisiche
390 ITVatNumberField
391 ----------------
393 A form field that validates Italian VAT numbers (partita IVA).
395 ITZipCodeField
396 --------------
398 A form field that validates input as an Italian zip code. Valid codes
399 must have five digits.
401 ITProvinceSelect
402 ----------------
404 A ``Select`` widget that uses a list of Italian provinces as its choices.
406 ITRegionSelect
407 --------------
409 A ``Select`` widget that uses a list of Italian regions as its choices.
411 Japan (``django.contrib.localflavor.jp``)
412 =========================================
414 JPPostalCodeField
415 -----------------
417 A form field that validates input as a Japanese postcode. It accepts seven
418 digits, with or without a hyphen.
420 JPPrefectureSelect
421 ------------------
423 A ``Select`` widget that uses a list of Japanese prefectures as its choices.
425 Mexico (``django.contrib.localflavor.mx``)
426 ==========================================
428 MXStateSelect
429 -------------
431 A ``Select`` widget that uses a list of Mexican states as its choices.
433 Norway (``django.contrib.localflavor.no``)
434 ==========================================
436 NOSocialSecurityNumber
437 ----------------------
439 A form field that validates input as a Norwegian social security number
440 (personnummer_).
442 .. _personnummer: http://no.wikipedia.org/wiki/Personnummer
444 NOZipCodeField
445 --------------
447 A form field that validates input as a Norwegian zip code. Valid codes
448 have four digits.
450 NOMunicipalitySelect
451 --------------------
453 A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
454 its choices.
456 Peru (``django.contrib.localflavor.pe``)
457 ========================================
459 PEDNIField
460 ----------
462 A form field that validates input as a DNI (Peruvian national identity)
463 number.
465 PERUCField
466 ----------
468 A form field that validates input as an RUC (Registro Unico de
469 Contribuyentes) number. Valid RUC numbers have 11 digits.
471 PEDepartmentSelect
472 ------------------
474 A ``Select`` widget that uses a list of Peruvian Departments as its choices.
476 Poland (``django.contrib.localflavor.pl``)
477 ==========================================
479 PLNationalIdentificationNumberField
480 -----------------------------------
482 A form field that validates input as a Polish national identification number
483 (PESEL_).
485 .. _PESEL: http://en.wikipedia.org/wiki/PESEL
487 PLNationalBusinessRegisterField
488 -------------------------------
490 A form field that validates input as a Polish National Official Business
491 Register Number (REGON_), having either seven or nine digits. The checksum
492 algorithm used for REGONs is documented at
493 http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
495 .. _REGON: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
497 PLPostalCodeField
498 -----------------
500 A form field that validates input as a Polish postal code. The valid format
501 is XX-XXX, where X is a digit.
503 PLTaxNumberField
504 ----------------
506 A form field that validates input as a Polish Tax Number (NIP). Valid
507 formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX. The checksum algorithm used
508 for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
510 PLAdministrativeUnitSelect
511 --------------------------
513 A ``Select`` widget that uses a list of Polish administrative units as its
514 choices.
516 PLVoivodeshipSelect
517 -------------------
519 A ``Select`` widget that uses a list of Polish voivodeships (administrative
520 provinces) as its choices.
522 Romania (``django.contrib.localflavor.ro``)
523 ============================================
525 ROCIFField
526 ----------
528 A form field that validates Romanian fiscal identification codes (CIF). The
529 return value strips the leading RO, if given.
531 ROCNPField
532 ----------
534 A form field that validates Romanian personal numeric codes (CNP).
536 ROCountyField
537 -------------
539 A form field that validates its input as a Romanian county (judet) name or
540 abbreviation. It normalizes the input to the standard vehicle registration
541 abbreviation for the given county. This field will only accept names written
542 with diacritics; consider using ROCountySelect as an alternative.
544 ROCountySelect
545 --------------
547 A ``Select`` widget that uses a list of Romanian counties (judete) as its
548 choices.
550 ROIBANField
551 -----------
553 A form field that validates its input as a Romanian International Bank 
554 Account Number (IBAN). The valid format is ROXX-XXXX-XXXX-XXXX-XXXX-XXXX,
555 with or without hyphens.
557 ROPhoneNumberField
558 ------------------
560 A form field that validates Romanian phone numbers, short special numbers
561 excluded.
563 ROPostalCodeField
564 -----------------
566 A form field that validates Romanian postal codes.
568 Slovakia (``django.contrib.localflavor.sk``)
569 ============================================
571 SKPostalCodeField
572 -----------------
574 A form field that validates input as a Slovak postal code. Valid formats
575 are XXXXX or XXX XX, where X is a digit.
577 SKDistrictSelect
578 ----------------
580 A ``Select`` widget that uses a list of Slovak districts as its choices.
582 SKRegionSelect
583 --------------
585 A ``Select`` widget that uses a list of Slovak regions as its choices.
587 South Africa (``django.contrib.localflavor.za``)
588 ================================================
590 ZAIDField
591 ---------
593 A form field that validates input as a South African ID number. Validation
594 uses the Luhn checksum and a simplistic (i.e., not entirely accurate) check
595 for birth date.
597 ZAPostCodeField
598 ---------------
600 A form field that validates input as a South African postcode. Valid
601 postcodes must have four digits.
603 Spain (``django.contrib.localflavor.es``)
604 =========================================
606 ESIdentityCardNumberField
607 -------------------------
609 A form field that validates input as a Spanish NIF/NIE/CIF (Fiscal
610 Identification Number) code.
612 ESCCCField
613 ----------
615 A form field that validates input as a Spanish bank account number (Codigo
616 Cuenta Cliente or CCC). A valid CCC number has the format
617 EEEE-OOOO-CC-AAAAAAAAAA, where the E, O, C and A digits denote the entity,
618 office, checksum and account, respectively. The first checksum digit
619 validates the entity and office. The second checksum digit validates the
620 account. It is also valid to use a space as a delimiter, or to use no
621 delimiter.
623 ESPhoneNumberField
624 ------------------
626 A form field that validates input as a Spanish phone number. Valid numbers
627 have nine digits, the first of which is 6, 8 or 9.
629 ESPostalCodeField
630 -----------------
632 A form field that validates input as a Spanish postal code. Valid codes
633 have five digits, the first two being in the range 01 to 52, representing
634 the province.
636 ESProvinceSelect
637 ----------------
639 A ``Select`` widget that uses a list of Spanish provinces as its choices.
641 ESRegionSelect
642 --------------
644 A ``Select`` widget that uses a list of Spanish regions as its choices.
646 Switzerland (``django.contrib.localflavor.ch``)
647 ===============================================
649 CHIdentityCardNumberField
650 -------------------------
652 A form field that validates input as a Swiss identity card number.
653 A valid number must confirm to the X1234567<0 or 1234567890 format and
654 have the correct checksums -- see http://adi.kousz.ch/artikel/IDCHE.htm.
656 CHPhoneNumberField
657 ------------------
659 A form field that validates input as a Swiss phone number. The correct
660 format is 0XX XXX XX XX. 0XX.XXX.XX.XX and 0XXXXXXXXX validate but are
661 corrected to 0XX XXX XX XX.
663 CHZipCodeField
664 --------------
666 A form field that validates input as a Swiss zip code. Valid codes
667 consist of four digits.
669 CHStateSelect
670 -------------
672 A ``Select`` widget that uses a list of Swiss states as its choices.
674 United Kingdom (``django.contrib.localflavor.uk``)
675 ==================================================
677 UKPostcodeField
678 ---------------
680 A form field that validates input as a UK postcode. The regular
681 expression used is sourced from the schema for British Standard BS7666
682 address types at http://www.govtalk.gov.uk/gdsc/schemas/bs7666-v2-0.xsd.
684 UKCountySelect
685 --------------
687 A ``Select`` widget that uses a list of UK counties/regions as its choices.
689 UKNationSelect
690 --------------
692 A ``Select`` widget that uses a list of UK nations as its choices.
694 United States of America (``django.contrib.localflavor.us``)
695 ============================================================
697 USPhoneNumberField
698 ------------------
700 A form field that validates input as a U.S. phone number.
702 USSocialSecurityNumberField
703 ---------------------------
705 A form field that validates input as a U.S. Social Security Number (SSN).
706 A valid SSN must obey the following rules:
708     * Format of XXX-XX-XXXX
709     * No group of digits consisting entirely of zeroes
710     * Leading group of digits cannot be 666
711     * Number not in promotional block 987-65-4320 through 987-65-4329
712     * Number not one known to be invalid due to widespread promotional
713       use or distribution (e.g., the Woolworth's number or the 1962
714       promotional number)
716 USStateField
717 ------------
719 A form field that validates input as a U.S. state name or abbreviation. It
720 normalizes the input to the standard two-letter postal service abbreviation
721 for the given state.
723 USZipCodeField
724 --------------
726 A form field that validates input as a U.S. ZIP code. Valid formats are
727 XXXXX or XXXXX-XXXX.
729 USStateSelect
730 -------------
732 A form ``Select`` widget that uses a list of U.S. states/territories as its
733 choices.