Django

Code

Ticket #3883: localflavor.5.txt

File localflavor.5.txt, 16.9 kB (added by nickefford, 7 months ago)

Final final version, incorporating za localflavor (rev 6843) and mx localflavor (#5676)

Line 
1 ==========================
2 The "local flavor" add-ons
3 ==========================
4
5 Django comes with assorted pieces of code that are useful only for a
6 particular country or culture.  These pieces of code are organized as a
7 set of subpackages, named using `ISO 3166 country codes`_.
8
9 .. _ISO 3166 country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
10
11 Most of the ``localflavor`` add-ons are localized form components deriving
12 from the newforms_ framework.  To use one of these localized components,
13 just import the relevant subpackage.  For example, a form with a field for
14 French telephone numbers is created like so::
15
16     from django import newforms as forms
17     from django.contrib.localflavor import fr
18
19     class MyForm(forms.Form):
20         my_french_phone_no = fr.forms.FRPhoneNumberField()
21
22 Countries currently supported by ``localflavor`` are:
23
24 * Argentina_
25 * Australia_
26 * Brazil_
27 * Canada_
28 * Chile_
29 * Finland_
30 * France_
31 * Germany_
32 * Holland_
33 * Iceland_
34 * India_
35 * Italy_
36 * Japan_
37 * Mexico_
38 * Norway_
39 * Peru_
40 * Poland_
41 * Slovakia_
42 * `South Africa`_
43 * Spain_
44 * Switzerland_
45 * `United Kingdom`_
46 * `United States of America`_
47
48 .. _Argentina: `Argentina (django.contrib.localflavor.ar)`_
49 .. _Australia: `Australia (django.contrib.localflavor.au)`_
50 .. _Brazil: `Brazil (django.contrib.localflavor.br)`_
51 .. _Canada: `Canada (django.contrib.localflavor.ca)`_
52 .. _Chile: `Chile (django.contrib.localflavor.cl)`_
53 .. _Finland: `Finland (django.contrib.localflavor.fi)`_
54 .. _France: `France (django.contrib.localflavor.fr)`_
55 .. _Germany: `Germany (django.contrib.localflavor.de)`_
56 .. _Holland: `Holland (django.contrib.localflavor.nl)`_
57 .. _Iceland: `Iceland (django.contrib.localflavor.is\_)`_
58 .. _India: `India (django.contrib.localflavor.in\_)`_
59 .. _Italy: `Italy (django.contrib.localflavor.it)`_
60 .. _Japan: `Japan (django.contrib.localflavor.jp)`_
61 .. _Mexico: `Mexico (django.contrib.localflavor.mx)`_
62 .. _Norway: `Norway (django.contrib.localflavor.no)`_
63 .. _Peru: `Peru (django.contrib.localflavor.pe)`_
64 .. _Poland: `Poland (django.contrib.localflavor.pl)`_
65 .. _Slovakia: `Slovakia (django.contrib.localflavor.sk)`_
66 .. _South Africa: `South Africa (django.contrib.localflavor.za)`_
67 .. _Spain: `Spain (django.contrib.localflavor.es)`_
68 .. _Switzerland: `Switzerland (django.contrib.localflavor.ch)`_
69 .. _United Kingdom: `United Kingdom (django.contrib.localflavor.uk)`_
70 .. _United States of America: `United States of America (django.contrib.localflavor.us)`_
71
72 The ``localflavor`` add-on also includes the ``generic`` subpackage,
73 containing useful code that is not specific to one particular country or
74 culture.  Currently, it defines date and date & time input fields based on
75 those from newforms_, but with non-US default formats.  Here's an example of
76 how to use them::
77
78     from django import newforms as forms
79     from django.contrib.localflavor import generic
80
81     class MyForm(forms.Form):
82         my_date_field = generic.forms.DateField()
83
84 .. _newforms: ../newforms/
85
86
87 .. admonition:: Adding a Flavor
88
89    We'd love to add more of these to Django, so please create a ticket for
90    anything that you've found useful. Please use unicode objects
91    (``u'mystring'``) for strings, rather than setting the encoding in the
92    file (see any of the existing flavors for examples).
93
94
95 Argentina (``django.contrib.localflavor.ar``)
96 =============================================
97
98 ARPostalCodeField
99 -----------------
100
101 A form field that validates input as either a classic four-digit
102 Argentinian postal code or a CPA_.
103
104 .. _CPA: http://www.correoargentino.com.ar/consulta_cpa/home.php
105
106 ARProvinceSelect
107 ----------------
108
109 A ``Select`` widget that uses a list of Argentina's provinces as its
110 choices.
111
112
113 Australia (``django.contrib.localflavor.au``)
114 =============================================
115
116 AUPostCodeField
117 ---------------
118
119 A form field that validates input as an Australian postcode.
120
121 AUPhoneNumberField
122 ------------------
123
124 A form field that validates input as an Australian phone number.  Valid
125 numbers have ten digits.
126
127 AUStateSelect
128 -------------
129
130 A ``Select`` widget that uses a list of Australian states/territories as its
131 choices.
132
133
134 Brazil (``django.contrib.localflavor.br``)
135 ==========================================
136
137 BRPhoneNumberField
138 ------------------
139
140 A form field that validates input as a Brazilian phone number, with the
141 format XX-XXXX-XXXX.
142
143 BRZipCodeField
144 --------------
145
146 A form field that validates input as a Brazilian zip code, with the format
147 XXXXX-XXX.
148
149 BRStateSelect
150 -------------
151
152 A ``Select`` widget that uses a list of Brazilian states/territories as its
153 choices.
154
155
156 Canada (``django.contrib.localflavor.ca``)
157 ==========================================
158
159 CAPhoneNumberField
160 ------------------
161
162 A form field that validates input as a Canadian phone number, with the
163 format XXX-XXX-XXXX.
164
165 CAPostalCodeField
166 -----------------
167
168 A form field that validates input as a Canadian postal code, with the
169 format XXX XXX.
170
171 CAProvinceField
172 ---------------
173
174 A form field that validates input as a Canadian province name or
175 abbreviation.
176
177 CASocialInsuranceNumberField
178 ----------------------------
179
180 A form field that validates input as a Canadian Social Insurance Number
181 (SIN).  A valid number must have the format XXX-XXX-XXXX and pass a
182 `Luhn mod-10 checksum`_.
183
184 .. _Luhn mod-10 checksum: http://en.wikipedia.org/wiki/Luhn_algorithm
185
186 CAProvinceSelect
187 ----------------
188
189 A ``Select`` widget that uses a list of Canadian provinces and territories
190 as its choices.
191
192
193 Chile (``django.contrib.localflavor.cl``)
194 =========================================
195
196 CLRutField
197 ----------
198
199 A form field that validates input as a Chilean national identification
200 number ('Rol Unico Tributario' or RUT).  The valid format is
201 XX.XXX.XXX-X.
202
203 CLRegionSelect
204 --------------
205
206 A ``Select`` widget that uses a list of Chilean regions (Regiones) as its
207 choices.
208
209
210 Finland (``django.contrib.localflavor.fi``)
211 ===========================================
212
213 FISocialSecurityNumber
214 ----------------------
215
216 A form field that validates input as a Finnish social security number.
217
218 FIZipCodeField
219 --------------
220
221 A form field that validates input as a Finnish zip code.  Valid codes
222 consist of five digits.
223
224 FIMunicipalitySelect
225 --------------------
226
227 A ``Select`` widget that uses a list of Finnish municipalities as its
228 choices.
229
230
231 France (``django.contrib.localflavor.fr``)
232 ==========================================
233
234 FRPhoneNumberField
235 ------------------
236
237 A form field that validates input as a French local phone number. The
238 correct format is 0X XX XX XX XX.  0X.XX.XX.XX.XX and 0XXXXXXXXX validate
239 but are corrected to 0X XX XX XX XX.
240
241 FRZipCodeField
242 --------------
243
244 A form field that validates input as a French zip code.  Valid codes
245 consist of five digits.
246
247 FRDepartmentSelect
248 ------------------
249
250 A ``Select`` widget that uses a list of French departments as its choices.
251
252
253 Germany (``django.contrib.localflavor.de``)
254 ===========================================
255
256 DEIdentityCardNumberField
257 -------------------------
258
259 A form field that validates input as a German identity card number
260 (Personalausweis_).  Valid numbers have the format
261 XXXXXXXXXXX-XXXXXXX-XXXXXXX-X, with no group consisting entirely of zeroes.
262
263 .. _Personalausweis: http://de.wikipedia.org/wiki/Personalausweis
264
265 DEZipCodeField
266 --------------
267
268 A form field that validates input as a German zip code.  Valid codes
269 consist of five digits.
270
271 DEStateSelect
272 -------------
273
274 A ``Select`` widget that uses a list of German states as its choices.
275
276
277 Holland (``django.contrib.localflavor.nl``)
278 ===========================================
279
280 NLPhoneNumberField
281 ------------------
282
283 A form field that validates input as a Dutch telephone number.
284
285 NLSofiNumberField
286 -----------------
287
288 A form field that validates input as a Dutch social security number
289 (SoFI/BSN).
290
291 NLZipCodeField
292 --------------
293
294 A form field that validates input as a Dutch zip code.
295
296 NLProvinceSelect
297 ----------------
298
299 A ``Select`` widget that uses a list of Dutch provinces as its list of
300 choices.
301
302
303 Iceland (``django.contrib.localflavor.is_``)
304 ============================================
305
306 ISIdNumberField
307 ---------------
308
309 A form field that validates input as an Icelandic identification number
310 (kennitala).  The format is XXXXXX-XXXX.
311
312 ISPhoneNumberField
313 ------------------
314
315 A form field that validates input as an Icelandtic phone number (seven
316 digits with an optional hyphen or space after the first three digits).
317
318 ISPostalCodeSelect
319 ------------------
320
321 A ``Select`` widget that uses a list of Icelandic postal codes as its
322 choices.
323
324
325 India (``django.contrib.localflavor.in_``)
326 ==========================================
327
328 INStateField
329 ------------
330
331 A form field that validates input as an Indian state/territory name or
332 abbreviation.  Input is normalized to the standard two-letter vehicle
333 registration abbreviation for the given state or territory.
334
335 INZipCodeField
336 --------------
337
338 A form field that validates input as an Indian zip code, with the
339 format XXXXXXX.
340
341 INStateSelect
342 -------------
343
344 A ``Select`` widget that uses a list of Indian states/territories as its
345 choices.
346
347
348 Italy (``django.contrib.localflavor.it``)
349 =========================================
350
351 ITSocialSecurityNumberField
352 ---------------------------
353
354 A form field that validates input as an Italian social security number
355 (`codice fiscale`_).
356
357 .. _codice fiscale: http://www.agenziaentrate.it/ilwwcm/connect/Nsi/Servizi/Codice+fiscale+-+tessera+sanitaria/Codice+fiscale/NSI+Informazioni+sulla+codificazione+delle+persone+fisiche
358
359 ITVatNumberField
360 ----------------
361
362 A form field that validates Italian VAT numbers (partita IVA).
363
364 ITZipCodeField
365 --------------
366
367 A form field that validates input as an Italian zip code.  Valid codes
368 must have five digits.
369
370 ITProvinceSelect
371 ----------------
372
373 A ``Select`` widget that uses a list of Italian provinces as its choices.
374
375 ITRegionSelect
376 --------------
377
378 A ``Select`` widget that uses a list of Italian regions as its choices.
379
380
381 Japan (``django.contrib.localflavor.jp``)
382 =========================================
383
384 JPPostalCodeField
385 -----------------
386
387 A form field that validates input as a Japanese postcode.
388 It accepts seven digits, with or without a hyphen.
389
390 JPPrefectureSelect
391 ------------------
392
393 A ``Select`` widget that uses a list of Japanese prefectures as its choices.
394
395
396 Mexico (``django.contrib.localflavor.mx``)
397 ==========================================
398
399 MXStateSelect
400 -------------
401
402 A ``Select`` widget that uses a list of Mexican states as its choices.
403
404
405 Norway (``django.contrib.localflavor.no``)
406 ==========================================
407
408 NOSocialSecurityNumber
409 ----------------------
410
411 A form field that validates input as a Norwegian social security number
412 (personnummer_).
413
414 .. _personnummer: http://no.wikipedia.org/wiki/Personnummer
415
416 NOZipCodeField
417 --------------
418
419 A form field that validates input as a Norwegian zip code.  Valid codes
420 have four digits.
421
422 NOMunicipalitySelect
423 --------------------
424
425 A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
426 its choices.
427
428
429 Peru (``django.contrib.localflavor.pe``)
430 ========================================
431
432 PEDNIField
433 ----------
434
435 A form field that validates input as a DNI (Peruvian national identity)
436 number.
437
438 PERUCField
439 ----------
440
441 A form field that validates input as an RUC (Registro Unico de
442 Contribuyentes) number.  Valid RUC numbers have eleven digits.
443
444 PEDepartmentSelect
445 ------------------
446
447 A ``Select`` widget that uses a list of Peruvian Departments as its choices.
448
449
450 Poland (``django.contrib.localflavor.pl``)
451 ==========================================
452
453 PLNationalIdentificationNumberField
454 -----------------------------------
455
456 A form field that validates input as a Polish national identification number
457 (PESEL_).
458
459 .. _PESEL: http://en.wikipedia.org/wiki/PESEL
460
461 PLNationalBusinessRegisterField
462 -------------------------------
463
464 A form field that validates input as a Polish National Official Business
465 Register Number (REGON_), having either seven or nine digits.  The checksum
466 algorithm used for REGONs is documented at
467 http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
468
469 .. _REGON: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
470
471 PLPostalCodeField
472 -----------------
473
474 A form field that validates input as a Polish postal code.  The valid format
475 is XX-XXX, where X is a digit.
476
477 PLTaxNumberField
478 ----------------
479
480 A form field that validates input as a Polish Tax Number (NIP).  Valid
481 formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX.  The checksum algorithm used
482 for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
483
484 PLAdministrativeUnitSelect
485 --------------------------
486
487 A ``Select`` widget that uses a list of Polish administrative units as its
488 choices.
489
490 PLVoivodeshipSelect
491 -------------------
492
493 A ``Select`` widget that uses a list of Polish voivodeships (administrative
494 provinces) as its choices.
495
496
497 Slovakia (``django.contrib.localflavor.sk``)
498 ============================================
499
500 SKPostalCodeField
501 -----------------
502
503 A form field that validates input as a Slovak postal code.  Valid formats
504 are XXXXX or XXX XX, where X is a digit.
505
506 SKDistrictSelect
507 ----------------
508
509 A ``Select`` widget that uses a list of Slovak districts as its choices.
510
511 SKRegionSelect
512 --------------
513
514 A ``Select`` widget that uses a list of Slovak regions as its choices.
515
516
517 South Africa (``django.contrib.localflavor.za``)
518 ================================================
519
520 ZAIDField
521 ---------
522
523 A form field that validates input as a South African ID number.  Validation
524 uses the Luhn checksum and a simplistic (i.e., not entirely accurate) check
525 for birth date.
526
527 ZAPostCodeField
528 ---------------
529
530 A form field that validates input as a South African postcode.  Valid
531 postcodes must have four digits.
532
533
534 Spain (``django.contrib.localflavor.es``)
535 =========================================
536
537 ESIdentityCardNumberField
538 -------------------------
539
540 A form field that validates input as a Spanish NIF/NIE/CIF (Fiscal
541 Identification Number) code.
542
543 ESCCCField
544 ----------
545
546 A form field that validates input as a Spanish bank account number (Codigo
547 Cuenta Cliente or CCC).  A valid CCC number has the format
548 EEEE-OOOO-CC-AAAAAAAAAA, where the E, O, C and A digits denote the entity,
549 office, checksum and account, respectively.  The first checksum digit
550 validates the entity and office.  The second checksum digit validates the
551 account.  It is also valid to use a space as a delimiter, or to use no
552 delimiter.
553
554 ESPhoneNumberField
555 ------------------
556
557 A form field that validates input as a Spanish phone number.  Valid numbers
558 have nine digits, the first of which is 6, 8 or 9.
559
560 ESPostalCodeField
561 -----------------
562
563 A form field that validates input as a Spanish postal code.  Valid codes
564 have five digits, the first two being in the range 01 to 52, representing
565 the province.
566
567 ESProvinceSelect
568 ----------------
569
570 A ``Select`` widget that uses a list of Spanish provinces as its choices.
571
572 ESRegionSelect
573 --------------
574
575 A ``Select`` widget that uses a list of Spanish regions as its choices.
576
577
578 Switzerland (``django.contrib.localflavor.ch``)
579 ===============================================
580
581 CHIdentityCardNumberField
582 -------------------------
583
584 A form field that validates input as a Swiss identity card number.
585 A valid number must confirm to the X1234567<0 or 1234567890 format and
586 have the correct checksums -- see http://adi.kousz.ch/artikel/IDCHE.htm.
587
588 CHPhoneNumberField
589 ------------------
590
591 A form field that validates input as a Swiss phone number.  The correct
592 format is 0XX XXX XX XX.  0XX.XXX.XX.XX and 0XXXXXXXXX validate but are
593 corrected to 0XX XXX XX XX.
594
595 CHZipCodeField
596 --------------
597
598 A form field that validates input as a Swiss zip code.  Valid codes
599 consist of four digits.
600
601 CHStateSelect
602 -------------
603
604 A ``Select`` widget that uses a list of Swiss states as its choices.
605
606
607 United Kingdom (``django.contrib.localflavor.uk``)
608 ==================================================
609
610 UKPostcodeField
611 ---------------
612
613 A form field that validates input as a UK postcode. The regular
614 expression used is sourced from the schema for British Standard BS7666
615 address types at http://www.govtalk.gov.uk/gdsc/schemas/bs7666-v2-0.xsd.
616
617
618 United States of America (``django.contrib.localflavor.us``)
619 ============================================================
620
621 USPhoneNumberField
622 ------------------
623
624 A form field that validates input as a U.S. phone number.
625
626 USSocialSecurityNumberField
627 ---------------------------
628
629 A form field that validates input as a U.S. Social Security Number (SSN).
630 A valid SSN must obey the following rules:
631
632 * Format of XXX-XX-XXXX
633 * No group of digits consisting entirely of zeroes
634 * Leading group of digits cannot be 666
635 * Number not in promotional block 987-65-4320 through 987-65-4329
636 * Number not one known to be invalid due to widespread promotional
637   use or distribution (e.g., the Woolworth's number or the 1962
638   promotional number)
639
640 USStateField
641 ------------
642
643 A form field that validates input as a U.S. state name or abbreviation. It
644 normalizes the input to the standard two-letter postal service abbreviation
645 for the given state.
646
647 USZipCodeField
648 --------------
649
650 A form field that validates input as a U.S. zip code.  Valid formats are
651 XXXXX or XXXXX-XXXX.
652
653 USStateSelect
654 -------------
655
656 A form Select widget that uses a list of U.S. states/territories as its
657 choices.