Ticket #3883: localflavor.txt

File localflavor.txt, 2.5 KB (added by Simon G. <dev@…>, 17 years ago)
Line 
1==========================
2The "local flavor" add-ons
3==========================
4
5A collection of various Django snippets that are useful only for a particular
6country or culture. For example, ``django.contrib.localflavor.usa.forms``
7contains a ``USZipCodeField`` that you can use to validate U.S. zip codes.
8
9These are mainly for newforms framework, to use these, just import the field
10you want, and use it in a form:
11
12 from django import newforms as forms
13 from django.contrib.localflavor import fr
14
15 class MyForm(forms.Form):
16 my_french_phone_no = fr.forms.FRPhoneNumberField()
17
18
19America (django.contrib.localflavor.usa)
20========================================
21
22USPhoneNumberField
23------------------
24
25A US Phone number field (XXX-XXX-XXXX format).
26
27USStateField
28------------
29
30A form field that validates its input is a U.S. state name or abbreviation. It
31normalizes the input to the standard two-leter postal service abbreviation for
32the given state.
33
34USStateSelect
35-------------
36
37A form Select widget that uses a list of U.S. states/territories as its choices.
38
39USZipCodeField
40--------------
41
42A field for US Zip codes, in the format XXXXX or XXXXX-XXXX.
43
44
45Britain (django.contrib.localflavor.uk)
46=======================================
47
48UKPostcodeField
49---------------
50
51A form field that validates its input is a UK postcode. The regular expression used
52is sourced from the schema for British Standard BS7666 address types at http://www.govtalk.gov.uk/gdsc/schemas/bs7666-v2-0.xsd
53
54
55France (django.contrib.localflavor.fr)
56======================================
57
58FRPhoneNumberField
59------------------
60
61Validates local French phone numbers. The correct format is '0X XX XX XX XX'.
62'0X.XX.XX.XX.XX' and '0XXXXXXXXX' validate but are corrected to '0X XX XX XX XX'.
63
64FRDepartmentSelect
65------------------
66
67A Select widget with a full list of FR departments.
68
69FRZipCodeField
70--------------
71
72A field for French zip codes in the format XXXXX.
73
74
75Japan (django.contrib.localflavor.jp)
76=====================================
77
78JPPostalCodeField
79-----------------
80
81A form field that validates its input is a Japanese postcode. Accepts 7 digits, with or without a hyphen.
82
83JPPrefectureSelect
84------------------
85
86A Select widget that uses a list of Japanese prefectures as its choices.
87
88
89Adding A Flavor
90===============
91
92We'd love to add more of these to Django, so please create a ticket for anything
93that you've found useful. Please use unicode objects (u'mystring') for strings,
94rather than setting the encoding in the file (see any of the existing flavors for
95examples).
96
97
Back to Top