PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/ref/contrib/localflavor.txt

https://code.google.com/p/mango-py/
Plain Text | 1036 lines | 678 code | 358 blank | 0 comment | 0 complexity | 555d874bdf88296411d4a9806b601813 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. ==========================
  2. The "local flavor" add-ons
  3. ==========================
  4. .. module:: django.contrib.localflavor
  5. :synopsis: A collection of various Django snippets that are useful only for
  6. a particular country or culture.
  7. Following its "batteries included" philosophy, Django comes with assorted
  8. pieces of code that are useful for particular countries or cultures. These are
  9. called the "local flavor" add-ons and live in the
  10. :mod:`django.contrib.localflavor` package.
  11. Inside that package, country- or culture-specific code is organized into
  12. subpackages, named using `ISO 3166 country codes`_.
  13. Most of the ``localflavor`` add-ons are localized form components deriving
  14. from the :doc:`forms </topics/forms/index>` framework -- for example, a
  15. :class:`~django.contrib.localflavor.us.forms.USStateField` that knows how to
  16. validate U.S. state abbreviations, and a
  17. :class:`~django.contrib.localflavor.fi.forms.FISocialSecurityNumber` that
  18. knows how to validate Finnish social security numbers.
  19. To use one of these localized components, just import the relevant subpackage.
  20. For example, here's how you can create a form with a field representing a
  21. French telephone number::
  22. from django import forms
  23. from django.contrib.localflavor.fr.forms import FRPhoneNumberField
  24. class MyForm(forms.Form):
  25. my_french_phone_no = FRPhoneNumberField()
  26. Supported countries
  27. ===================
  28. Countries currently supported by :mod:`~django.contrib.localflavor` are:
  29. * Argentina_
  30. * Australia_
  31. * Austria_
  32. * Belgium_
  33. * Brazil_
  34. * Canada_
  35. * Chile_
  36. * Czech_
  37. * Finland_
  38. * France_
  39. * Germany_
  40. * Iceland_
  41. * India_
  42. * Indonesia_
  43. * Ireland_
  44. * Israel_
  45. * Italy_
  46. * Japan_
  47. * Kuwait_
  48. * Mexico_
  49. * `The Netherlands`_
  50. * Norway_
  51. * Peru_
  52. * Poland_
  53. * Portugal_
  54. * Romania_
  55. * Slovakia_
  56. * `South Africa`_
  57. * Spain_
  58. * Sweden_
  59. * Switzerland_
  60. * Turkey_
  61. * `United Kingdom`_
  62. * `United States of America`_
  63. * Uruguay_
  64. The ``django.contrib.localflavor`` package also includes a ``generic`` subpackage,
  65. containing useful code that is not specific to one particular country or culture.
  66. Currently, it defines date, datetime and split datetime input fields based on
  67. those from :doc:`forms </topics/forms/index>`, but with non-US default formats.
  68. Here's an example of how to use them::
  69. from django import forms
  70. from django.contrib.localflavor import generic
  71. class MyForm(forms.Form):
  72. my_date_field = generic.forms.DateField()
  73. .. _ISO 3166 country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
  74. .. _Argentina: `Argentina (ar)`_
  75. .. _Australia: `Australia (au)`_
  76. .. _Austria: `Austria (at)`_
  77. .. _Belgium: `Belgium (be)`_
  78. .. _Brazil: `Brazil (br)`_
  79. .. _Canada: `Canada (ca)`_
  80. .. _Chile: `Chile (cl)`_
  81. .. _Czech: `Czech (cz)`_
  82. .. _Finland: `Finland (fi)`_
  83. .. _France: `France (fr)`_
  84. .. _Germany: `Germany (de)`_
  85. .. _The Netherlands: `The Netherlands (nl)`_
  86. .. _Iceland: `Iceland (is\_)`_
  87. .. _India: `India (in\_)`_
  88. .. _Indonesia: `Indonesia (id)`_
  89. .. _Ireland: `Ireland (ie)`_
  90. .. _Israel: `Israel (il)`_
  91. .. _Italy: `Italy (it)`_
  92. .. _Japan: `Japan (jp)`_
  93. .. _Kuwait: `Kuwait (kw)`_
  94. .. _Mexico: `Mexico (mx)`_
  95. .. _Norway: `Norway (no)`_
  96. .. _Peru: `Peru (pe)`_
  97. .. _Poland: `Poland (pl)`_
  98. .. _Portugal: `Portugal (pt)`_
  99. .. _Romania: `Romania (ro)`_
  100. .. _Slovakia: `Slovakia (sk)`_
  101. .. _South Africa: `South Africa (za)`_
  102. .. _Spain: `Spain (es)`_
  103. .. _Sweden: `Sweden (se)`_
  104. .. _Switzerland: `Switzerland (ch)`_
  105. .. _Turkey: `Turkey (tr)`_
  106. .. _United Kingdom: `United Kingdom (uk)`_
  107. .. _United States of America: `United States of America (us)`_
  108. .. _Uruguay: `Uruguay (uy)`_
  109. Internationalization of localflavor
  110. ===================================
  111. Localflavor has its own catalog of translations, in the directory
  112. ``django/contrib/localflavor/locale``, and it's not loaded automatically like
  113. Django's general catalog in ``django/conf/locale``. If you want localflavor's
  114. texts to be translated, like form fields error messages, you must include
  115. :mod:`django.contrib.localflavor` in the :setting:`INSTALLED_APPS` setting, so
  116. the internationalization system can find the catalog, as explained in
  117. :ref:`using-translations-in-your-own-projects`.
  118. Adding flavors
  119. ==============
  120. We'd love to add more of these to Django, so please `create a ticket`_ with
  121. any code you'd like to contribute. One thing we ask is that you please use
  122. Unicode objects (``u'mystring'``) for strings, rather than setting the encoding
  123. in the file. See any of the existing flavors for examples.
  124. .. _create a ticket: http://code.djangoproject.com/simpleticket
  125. Localflavor and backwards compatibility
  126. =======================================
  127. As documented in our :ref:`API stability
  128. <misc-api-stability-localflavor>` policy, Django will always attempt
  129. to make :mod:`django.contrib.localflavor` reflect the officially
  130. gazetted policies of the appropriate local government authority. For
  131. example, if a government body makes a change to add, alter, or remove
  132. a province (or state, or county), that change will be reflected in
  133. Django's localflavor in the next stable Django release.
  134. When a backwards-incompatible change is made (for example, the removal
  135. or renaming of a province) the localflavor in question will raise a
  136. warning when that localflavor is imported. This provides a runtime
  137. indication that something may require attention.
  138. However, once you have addressed the backwards compatibility (for
  139. example, auditing your code to see if any data migration is required),
  140. the warning serves no purpose. The warning can then be supressed.
  141. For example, to suppress the warnings raised by the Indonesian
  142. localflavor you would use the following code::
  143. import warnings
  144. warnings.filterwarnings('ignore',
  145. category=RuntimeWarning,
  146. module='django.contrib.localflavor.id')
  147. from django.contrib.localflavor.id import forms as id_forms
  148. Argentina (``ar``)
  149. =============================================
  150. .. class:: ar.forms.ARPostalCodeField
  151. A form field that validates input as either a classic four-digit Argentinian
  152. postal code or a CPA_.
  153. .. _CPA: http://www.correoargentino.com.ar/consulta_cpa/home.php
  154. .. class:: ar.forms.ARDNIField
  155. A form field that validates input as a Documento Nacional de Identidad (DNI)
  156. number.
  157. .. class:: ar.forms.ARCUITField
  158. A form field that validates input as a Codigo Unico de Identificacion
  159. Tributaria (CUIT) number.
  160. .. class:: ar.forms.ARProvinceSelect
  161. A ``Select`` widget that uses a list of Argentina's provinces and autonomous
  162. cities as its choices.
  163. Australia (``au``)
  164. =============================================
  165. .. class:: au.forms.AUPostCodeField
  166. A form field that validates input as an Australian postcode.
  167. .. class:: au.forms.AUPhoneNumberField
  168. A form field that validates input as an Australian phone number. Valid numbers
  169. have ten digits.
  170. .. class:: au.forms.AUStateSelect
  171. A ``Select`` widget that uses a list of Australian states/territories as its
  172. choices.
  173. Austria (``at``)
  174. ================
  175. .. class:: at.forms.ATZipCodeField
  176. A form field that validates its input as an Austrian zip code.
  177. .. class:: at.forms.ATStateSelect
  178. A ``Select`` widget that uses a list of Austrian states as its choices.
  179. .. class:: at.forms.ATSocialSecurityNumberField
  180. A form field that validates its input as an Austrian social security number.
  181. Belgium (``be``)
  182. ================
  183. .. versionadded:: 1.3
  184. .. class:: be.forms.BEPhoneNumberField
  185. A form field that validates input as a Belgium phone number, with one of
  186. the formats 0x xxx xx xx, 0xx xx xx xx, 04xx xx xx xx, 0x/xxx.xx.xx,
  187. 0xx/xx.xx.xx, 04xx/xx.xx.xx, 0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx,
  188. 0xxxxxxxx or 04xxxxxxxx.
  189. .. class:: be.forms.BEPostalCodeField
  190. A form field that validates input as a Belgium postal code, in the range
  191. and format 1XXX-9XXX.
  192. .. class:: be.forms.BEProvinceSelect
  193. A ``Select`` widget that uses a list of Belgium provinces as its
  194. choices.
  195. .. class:: be.forms.BERegionSelect
  196. A ``Select`` widget that uses a list of Belgium regions as its
  197. choices.
  198. Brazil (``br``)
  199. ===============
  200. .. class:: br.forms.BRPhoneNumberField
  201. A form field that validates input as a Brazilian phone number, with the format
  202. XX-XXXX-XXXX.
  203. .. class:: br.forms.BRZipCodeField
  204. A form field that validates input as a Brazilian zip code, with the format
  205. XXXXX-XXX.
  206. .. class:: br.forms.BRStateSelect
  207. A ``Select`` widget that uses a list of Brazilian states/territories as its
  208. choices.
  209. .. class:: br.forms.BRCPFField
  210. A form field that validates input as `Brazilian CPF`_.
  211. Input can either be of the format XXX.XXX.XXX-VD or be a group of 11 digits.
  212. .. _Brazilian CPF: http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas
  213. .. class:: br.forms.BRCNPJField
  214. A form field that validates input as `Brazilian CNPJ`_.
  215. Input can either be of the format XX.XXX.XXX/XXXX-XX or be a group of 14
  216. digits.
  217. .. _Brazilian CNPJ: http://en.wikipedia.org/wiki/National_identification_number#Brazil
  218. Canada (``ca``)
  219. ===============
  220. .. class:: ca.forms.CAPhoneNumberField
  221. A form field that validates input as a Canadian phone number, with the format
  222. XXX-XXX-XXXX.
  223. .. class:: ca.forms.CAPostalCodeField
  224. A form field that validates input as a Canadian postal code, with the format
  225. XXX XXX.
  226. .. class:: ca.forms.CAProvinceField
  227. A form field that validates input as a Canadian province name or abbreviation.
  228. .. class:: ca.forms.CASocialInsuranceNumberField
  229. A form field that validates input as a Canadian Social Insurance Number (SIN).
  230. A valid number must have the format XXX-XXX-XXX and pass a `Luhn mod-10
  231. checksum`_.
  232. .. _Luhn mod-10 checksum: http://en.wikipedia.org/wiki/Luhn_algorithm
  233. .. class:: ca.forms.CAProvinceSelect
  234. A ``Select`` widget that uses a list of Canadian provinces and territories as
  235. its choices.
  236. Chile (``cl``)
  237. ==============
  238. .. class:: cl.forms.CLRutField
  239. A form field that validates input as a Chilean national identification number
  240. ('Rol Unico Tributario' or RUT). The valid format is XX.XXX.XXX-X.
  241. .. class:: cl.forms.CLRegionSelect
  242. A ``Select`` widget that uses a list of Chilean regions (Regiones) as its
  243. choices.
  244. Czech (``cz``)
  245. ==============
  246. .. class:: cz.forms.CZPostalCodeField
  247. A form field that validates input as a Czech postal code. Valid formats
  248. are XXXXX or XXX XX, where X is a digit.
  249. .. class:: cz.forms.CZBirthNumberField
  250. A form field that validates input as a Czech Birth Number.
  251. A valid number must be in format XXXXXX/XXXX (slash is optional).
  252. .. class:: cz.forms.CZICNumberField
  253. A form field that validates input as a Czech IC number field.
  254. .. class:: cz.forms.CZRegionSelect
  255. A ``Select`` widget that uses a list of Czech regions as its choices.
  256. Finland (``fi``)
  257. ================
  258. .. class:: fi.forms.FISocialSecurityNumber
  259. A form field that validates input as a Finnish social security number.
  260. .. class:: fi.forms.FIZipCodeField
  261. A form field that validates input as a Finnish zip code. Valid codes
  262. consist of five digits.
  263. .. class:: fi.forms.FIMunicipalitySelect
  264. A ``Select`` widget that uses a list of Finnish municipalities as its
  265. choices.
  266. France (``fr``)
  267. ===============
  268. .. class:: fr.forms.FRPhoneNumberField
  269. A form field that validates input as a French local phone number. The
  270. correct format is 0X XX XX XX XX. 0X.XX.XX.XX.XX and 0XXXXXXXXX validate
  271. but are corrected to 0X XX XX XX XX.
  272. .. class:: fr.forms.FRZipCodeField
  273. A form field that validates input as a French zip code. Valid codes
  274. consist of five digits.
  275. .. class:: fr.forms.FRDepartmentSelect
  276. A ``Select`` widget that uses a list of French departments as its choices.
  277. Germany (``de``)
  278. ================
  279. .. class:: de.forms.DEIdentityCardNumberField
  280. A form field that validates input as a German identity card number
  281. (Personalausweis_). Valid numbers have the format
  282. XXXXXXXXXXX-XXXXXXX-XXXXXXX-X, with no group consisting entirely of zeroes.
  283. .. _Personalausweis: http://de.wikipedia.org/wiki/Personalausweis
  284. .. class:: de.forms.DEZipCodeField
  285. A form field that validates input as a German zip code. Valid codes
  286. consist of five digits.
  287. .. class:: de.forms.DEStateSelect
  288. A ``Select`` widget that uses a list of German states as its choices.
  289. The Netherlands (``nl``)
  290. ========================
  291. .. class:: nl.forms.NLPhoneNumberField
  292. A form field that validates input as a Dutch telephone number.
  293. .. class:: nl.forms.NLSofiNumberField
  294. A form field that validates input as a Dutch social security number
  295. (SoFI/BSN).
  296. .. class:: nl.forms.NLZipCodeField
  297. A form field that validates input as a Dutch zip code.
  298. .. class:: nl.forms.NLProvinceSelect
  299. A ``Select`` widget that uses a list of Dutch provinces as its list of
  300. choices.
  301. Iceland (``is_``)
  302. =================
  303. .. class:: is_.forms.ISIdNumberField
  304. A form field that validates input as an Icelandic identification number
  305. (kennitala). The format is XXXXXX-XXXX.
  306. .. class:: is_.forms.ISPhoneNumberField
  307. A form field that validates input as an Icelandtic phone number (seven
  308. digits with an optional hyphen or space after the first three digits).
  309. .. class:: is_.forms.ISPostalCodeSelect
  310. A ``Select`` widget that uses a list of Icelandic postal codes as its
  311. choices.
  312. India (``in_``)
  313. ===============
  314. .. class:: in.forms.INStateField
  315. A form field that validates input as an Indian state/territory name or
  316. abbreviation. Input is normalized to the standard two-letter vehicle
  317. registration abbreviation for the given state or territory.
  318. .. class:: in.forms.INZipCodeField
  319. A form field that validates input as an Indian zip code, with the
  320. format XXXXXXX.
  321. .. class:: in.forms.INStateSelect
  322. A ``Select`` widget that uses a list of Indian states/territories as its
  323. choices.
  324. Ireland (``ie``)
  325. ================
  326. .. class:: ie.forms.IECountySelect
  327. A ``Select`` widget that uses a list of Irish Counties as its choices.
  328. Indonesia (``id``)
  329. ==================
  330. .. class:: id.forms.IDPostCodeField
  331. A form field that validates input as an Indonesian post code field.
  332. .. class:: id.forms.IDProvinceSelect
  333. A ``Select`` widget that uses a list of Indonesian provinces as its choices.
  334. .. versionchanged:: 1.3
  335. The province "Nanggroe Aceh Darussalam (NAD)" has been removed
  336. from the province list in favor of the new official designation
  337. "Aceh (ACE)".
  338. .. class:: id.forms.IDPhoneNumberField
  339. A form field that validates input as an Indonesian telephone number.
  340. .. class:: id.forms.IDLicensePlatePrefixSelect
  341. A ``Select`` widget that uses a list of Indonesian license plate
  342. prefix code as its choices.
  343. .. class:: id.forms.IDLicensePlateField
  344. A form field that validates input as an Indonesian vehicle license plate.
  345. .. class:: id.forms.IDNationalIdentityNumberField
  346. A form field that validates input as an Indonesian national identity
  347. number (`NIK`_/KTP). The output will be in the format of
  348. 'XX.XXXX.DDMMYY.XXXX'. Dots or spaces can be used in the input to break
  349. down the numbers.
  350. .. _NIK: http://en.wikipedia.org/wiki/Indonesian_identity_card
  351. Israel (``il``)
  352. ===============
  353. .. class:: il.forms.ILPostalCodeField
  354. A form field that validates its input as an Israeli five-digit postal code.
  355. .. class:: il.forms.ILIDNumberField
  356. A form field that validates its input as an `Israeli identification number`_.
  357. The output will be in the format of a 2-9 digit number, consisting of a
  358. 1-8 digit ID number followed by a single checksum digit, calculated using
  359. the `Luhn algorithm`_.
  360. Input may contain an optional hyphen separating the ID number from the checksum
  361. digit.
  362. .. _Israeli identification number: http://he.wikipedia.org/wiki/%D7%9E%D7%A1%D7%A4%D7%A8_%D7%96%D7%94%D7%95%D7%AA_(%D7%99%D7%A9%D7%A8%D7%90%D7%9C)
  363. .. _Luhn algorithm: http://en.wikipedia.org/wiki/Luhn_algorithm
  364. Italy (``it``)
  365. ==============
  366. .. class:: it.forms.ITSocialSecurityNumberField
  367. A form field that validates input as an Italian social security number
  368. (`codice fiscale`_).
  369. .. _codice fiscale: http://www.agenziaentrate.it/ilwwcm/connect/Nsi/Servizi/Codice+fiscale+-+tessera+sanitaria/NSI+Informazioni+sulla+codificazione+delle+persone+fisiche
  370. .. class:: it.forms.ITVatNumberField
  371. A form field that validates Italian VAT numbers (partita IVA).
  372. .. class:: it.forms.ITZipCodeField
  373. A form field that validates input as an Italian zip code. Valid codes
  374. must have five digits.
  375. .. class:: it.forms.ITProvinceSelect
  376. A ``Select`` widget that uses a list of Italian provinces as its choices.
  377. .. class:: it.forms.ITRegionSelect
  378. A ``Select`` widget that uses a list of Italian regions as its choices.
  379. Japan (``jp``)
  380. ==============
  381. .. class:: jp.forms.JPPostalCodeField
  382. A form field that validates input as a Japanese postcode. It accepts seven
  383. digits, with or without a hyphen.
  384. .. class:: jp.forms.JPPrefectureSelect
  385. A ``Select`` widget that uses a list of Japanese prefectures as its choices.
  386. Kuwait (``kw``)
  387. ===============
  388. .. class:: kw.forms.KWCivilIDNumberField
  389. A form field that validates input as a Kuwaiti Civil ID number. A valid
  390. Civil ID number must obey the following rules:
  391. * The number consist of 12 digits.
  392. * The birthdate of the person is a valid date.
  393. * The calculated checksum equals to the last digit of the Civil ID.
  394. Mexico (``mx``)
  395. ===============
  396. .. class:: mx.forms.MXStateSelect
  397. A ``Select`` widget that uses a list of Mexican states as its choices.
  398. Norway (``no``)
  399. ===============
  400. .. class:: no.forms.NOSocialSecurityNumber
  401. A form field that validates input as a Norwegian social security number
  402. (personnummer_).
  403. .. _personnummer: http://no.wikipedia.org/wiki/Personnummer
  404. .. class:: no.forms.NOZipCodeField
  405. A form field that validates input as a Norwegian zip code. Valid codes
  406. have four digits.
  407. .. class:: no.forms.NOMunicipalitySelect
  408. A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
  409. its choices.
  410. Peru (``pe``)
  411. =============
  412. .. class:: pe.forms.PEDNIField
  413. A form field that validates input as a DNI (Peruvian national identity)
  414. number.
  415. .. class:: pe.forms.PERUCField
  416. A form field that validates input as an RUC (Registro Unico de
  417. Contribuyentes) number. Valid RUC numbers have 11 digits.
  418. .. class:: pe.forms.PEDepartmentSelect
  419. A ``Select`` widget that uses a list of Peruvian Departments as its choices.
  420. Poland (``pl``)
  421. ===============
  422. .. class:: pl.forms.PLPESELField
  423. A form field that validates input as a Polish national identification number
  424. (PESEL_).
  425. .. _PESEL: http://en.wikipedia.org/wiki/PESEL
  426. .. class:: pl.forms.PLREGONField
  427. A form field that validates input as a Polish National Official Business
  428. Register Number (REGON_), having either seven or nine digits. The checksum
  429. algorithm used for REGONs is documented at
  430. http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
  431. .. _REGON: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
  432. .. class:: pl.forms.PLPostalCodeField
  433. A form field that validates input as a Polish postal code. The valid format
  434. is XX-XXX, where X is a digit.
  435. .. class:: pl.forms.PLNIPField
  436. A form field that validates input as a Polish Tax Number (NIP). Valid
  437. formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX. The checksum algorithm used
  438. for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
  439. .. class:: pl.forms.PLCountySelect
  440. A ``Select`` widget that uses a list of Polish administrative units as its
  441. choices.
  442. .. class:: pl.forms.PLProvinceSelect
  443. A ``Select`` widget that uses a list of Polish voivodeships (administrative
  444. provinces) as its choices.
  445. Portugal (``pt``)
  446. =================
  447. .. class:: pt.forms.PTZipCodeField
  448. A form field that validates input as a Portuguese zip code.
  449. .. class:: pt.forms.PTPhoneNumberField
  450. A form field that validates input as a Portuguese phone number.
  451. Valid numbers have 9 digits (may include spaces) or start by 00
  452. or + (international).
  453. Romania (``ro``)
  454. ================
  455. .. class:: ro.forms.ROCIFField
  456. A form field that validates Romanian fiscal identification codes (CIF). The
  457. return value strips the leading RO, if given.
  458. .. class:: ro.forms.ROCNPField
  459. A form field that validates Romanian personal numeric codes (CNP).
  460. .. class:: ro.forms.ROCountyField
  461. A form field that validates its input as a Romanian county (judet) name or
  462. abbreviation. It normalizes the input to the standard vehicle registration
  463. abbreviation for the given county. This field will only accept names written
  464. with diacritics; consider using ROCountySelect as an alternative.
  465. .. class:: ro.forms.ROCountySelect
  466. A ``Select`` widget that uses a list of Romanian counties (judete) as its
  467. choices.
  468. .. class:: ro.forms.ROIBANField
  469. A form field that validates its input as a Romanian International Bank
  470. Account Number (IBAN). The valid format is ROXX-XXXX-XXXX-XXXX-XXXX-XXXX,
  471. with or without hyphens.
  472. .. class:: ro.forms.ROPhoneNumberField
  473. A form field that validates Romanian phone numbers, short special numbers
  474. excluded.
  475. .. class:: ro.forms.ROPostalCodeField
  476. A form field that validates Romanian postal codes.
  477. Slovakia (``sk``)
  478. =================
  479. .. class:: sk.forms.SKPostalCodeField
  480. A form field that validates input as a Slovak postal code. Valid formats
  481. are XXXXX or XXX XX, where X is a digit.
  482. .. class:: sk.forms.SKDistrictSelect
  483. A ``Select`` widget that uses a list of Slovak districts as its choices.
  484. .. class:: sk.forms.SKRegionSelect
  485. A ``Select`` widget that uses a list of Slovak regions as its choices.
  486. South Africa (``za``)
  487. =====================
  488. .. class:: za.forms.ZAIDField
  489. A form field that validates input as a South African ID number. Validation
  490. uses the Luhn checksum and a simplistic (i.e., not entirely accurate) check
  491. for birth date.
  492. .. class:: za.forms.ZAPostCodeField
  493. A form field that validates input as a South African postcode. Valid
  494. postcodes must have four digits.
  495. Spain (``es``)
  496. ==============
  497. .. class:: es.forms.ESIdentityCardNumberField
  498. A form field that validates input as a Spanish NIF/NIE/CIF (Fiscal
  499. Identification Number) code.
  500. .. class:: es.forms.ESCCCField
  501. A form field that validates input as a Spanish bank account number (Codigo
  502. Cuenta Cliente or CCC). A valid CCC number has the format
  503. EEEE-OOOO-CC-AAAAAAAAAA, where the E, O, C and A digits denote the entity,
  504. office, checksum and account, respectively. The first checksum digit
  505. validates the entity and office. The second checksum digit validates the
  506. account. It is also valid to use a space as a delimiter, or to use no
  507. delimiter.
  508. .. class:: es.forms.ESPhoneNumberField
  509. A form field that validates input as a Spanish phone number. Valid numbers
  510. have nine digits, the first of which is 6, 8 or 9.
  511. .. class:: es.forms.ESPostalCodeField
  512. A form field that validates input as a Spanish postal code. Valid codes
  513. have five digits, the first two being in the range 01 to 52, representing
  514. the province.
  515. .. class:: es.forms.ESProvinceSelect
  516. A ``Select`` widget that uses a list of Spanish provinces as its choices.
  517. .. class:: es.forms.ESRegionSelect
  518. A ``Select`` widget that uses a list of Spanish regions as its choices.
  519. Sweden (``se``)
  520. ===============
  521. .. class:: se.forms.SECountySelect
  522. A Select form widget that uses a list of the Swedish counties (l?n) as its
  523. choices.
  524. The cleaned value is the official county code -- see
  525. http://en.wikipedia.org/wiki/Counties_of_Sweden for a list.
  526. .. class:: se.forms.SEOrganisationNumber
  527. A form field that validates input as a Swedish organisation number
  528. (organisationsnummer).
  529. It accepts the same input as SEPersonalIdentityField (for sole
  530. proprietorships (enskild firma). However, co-ordination numbers are not
  531. accepted.
  532. It also accepts ordinary Swedish organisation numbers with the format
  533. NNNNNNNNNN.
  534. The return value will be YYYYMMDDXXXX for sole proprietors, and NNNNNNNNNN
  535. for other organisations.
  536. .. class:: se.forms.SEPersonalIdentityNumber
  537. A form field that validates input as a Swedish personal identity number
  538. (personnummer).
  539. The correct formats are YYYYMMDD-XXXX, YYYYMMDDXXXX, YYMMDD-XXXX,
  540. YYMMDDXXXX and YYMMDD+XXXX.
  541. A \+ indicates that the person is older than 100 years, which will be taken
  542. into consideration when the date is validated.
  543. The checksum will be calculated and checked. The birth date is checked
  544. to be a valid date.
  545. By default, co-ordination numbers (samordningsnummer) will be accepted. To
  546. only allow real personal identity numbers, pass the keyword argument
  547. coordination_number=False to the constructor.
  548. The cleaned value will always have the format YYYYMMDDXXXX.
  549. .. class:: se.forms.SEPostalCodeField
  550. A form field that validates input as a Swedish postal code (postnummer).
  551. Valid codes consist of five digits (XXXXX). The number can optionally be
  552. formatted with a space after the third digit (XXX XX).
  553. The cleaned value will never contain the space.
  554. Switzerland (``ch``)
  555. ====================
  556. .. class:: ch.forms.CHIdentityCardNumberField
  557. A form field that validates input as a Swiss identity card number.
  558. A valid number must confirm to the X1234567<0 or 1234567890 format and
  559. have the correct checksums.
  560. .. class:: ch.forms.CHPhoneNumberField
  561. A form field that validates input as a Swiss phone number. The correct
  562. format is 0XX XXX XX XX. 0XX.XXX.XX.XX and 0XXXXXXXXX validate but are
  563. corrected to 0XX XXX XX XX.
  564. .. class:: ch.forms.CHZipCodeField
  565. A form field that validates input as a Swiss zip code. Valid codes
  566. consist of four digits.
  567. .. class:: ch.forms.CHStateSelect
  568. A ``Select`` widget that uses a list of Swiss states as its choices.
  569. Turkey (``tr``)
  570. ===============
  571. .. class:: tr.forms.TRZipCodeField
  572. A form field that validates input as a Turkish zip code. Valid codes
  573. consist of five digits.
  574. .. class:: tr.forms.TRPhoneNumberField
  575. A form field that validates input as a Turkish phone number. The correct
  576. format is 0xxx xxx xxxx. +90xxx xxx xxxx and inputs without spaces also
  577. validates. The result is normalized to xxx xxx xxxx format.
  578. .. class:: tr.forms.TRIdentificationNumberField
  579. A form field that validates input as a TR identification number. A valid
  580. number must satisfy the following:
  581. * The number consist of 11 digits.
  582. * The first digit cannot be 0.
  583. * (sum(1st, 3rd, 5th, 7th, 9th)*7 - sum(2nd,4th,6th,8th)) % 10) must be
  584. equal to the 10th digit.
  585. * (sum(1st to 10th) % 10) must be equal to the 11th digit.
  586. .. class:: tr.forms.TRProvinceSelect
  587. A ``select`` widget that uses a list of Turkish provinces as its choices.
  588. United Kingdom (``uk``)
  589. =======================
  590. .. class:: uk.forms.UKPostcodeField
  591. A form field that validates input as a UK postcode. The regular
  592. expression used is sourced from the schema for British Standard BS7666
  593. address types at http://www.cabinetoffice.gov.uk/media/291293/bs7666-v2-0.xml.
  594. .. class:: uk.forms.UKCountySelect
  595. A ``Select`` widget that uses a list of UK counties/regions as its choices.
  596. .. class:: uk.forms.UKNationSelect
  597. A ``Select`` widget that uses a list of UK nations as its choices.
  598. United States of America (``us``)
  599. =================================
  600. .. class:: us.forms.USPhoneNumberField
  601. A form field that validates input as a U.S. phone number.
  602. .. class:: us.forms.USSocialSecurityNumberField
  603. A form field that validates input as a U.S. Social Security Number (SSN).
  604. A valid SSN must obey the following rules:
  605. * Format of XXX-XX-XXXX
  606. * No group of digits consisting entirely of zeroes
  607. * Leading group of digits cannot be 666
  608. * Number not in promotional block 987-65-4320 through 987-65-4329
  609. * Number not one known to be invalid due to widespread promotional
  610. use or distribution (e.g., the Woolworth's number or the 1962
  611. promotional number)
  612. .. class:: us.forms.USStateField
  613. A form field that validates input as a U.S. state name or abbreviation. It
  614. normalizes the input to the standard two-letter postal service abbreviation
  615. for the given state.
  616. .. class:: us.forms.USZipCodeField
  617. A form field that validates input as a U.S. ZIP code. Valid formats are
  618. XXXXX or XXXXX-XXXX.
  619. .. class:: us.forms.USStateSelect
  620. A form ``Select`` widget that uses a list of U.S. states/territories as its
  621. choices.
  622. .. class:: us.forms.USPSSelect
  623. A form ``Select`` widget that uses a list of U.S Postal Service
  624. state, territory and country abbreviations as its choices.
  625. .. class:: us.models.PhoneNumberField
  626. A :class:`CharField` that checks that the value is a valid U.S.A.-style phone
  627. number (in the format ``XXX-XXX-XXXX``).
  628. .. class:: us.models.USStateField
  629. A model field that forms represent as a ``forms.USStateField`` field and
  630. stores the two-letter U.S. state abbreviation in the database.
  631. .. class:: us.models.USPostalCodeField
  632. A model field that forms represent as a ``forms.USPSSelect`` field
  633. and stores the two-letter U.S Postal Service abbreviation in the
  634. database.
  635. Additionally, a variety of choice tuples are provided in
  636. ``django.contrib.localflavor.us.us_states``, allowing customized model
  637. and form fields, and form presentations, for subsets of U.S states,
  638. territories and U.S Postal Service abbreviations:
  639. .. data:: us.us_states.CONTIGUOUS_STATES
  640. A tuple of choices of the postal abbreviations for the
  641. contiguous or "lower 48" states (i.e., all except Alaska and
  642. Hawaii), plus the District of Columbia.
  643. .. data:: us.us_states.US_STATES
  644. A tuple of choices of the postal abbreviations for all
  645. 50 U.S. states, plus the District of Columbia.
  646. .. data:: us.us_states.US_TERRITORIES
  647. A tuple of choices of the postal abbreviations for U.S
  648. territories: American Samoa, Guam, the Northern Mariana Islands,
  649. Puerto Rico and the U.S. Virgin Islands.
  650. .. data:: us.us_states.ARMED_FORCES_STATES
  651. A tuple of choices of the postal abbreviations of the three U.S
  652. military postal "states": Armed Forces Americas, Armed Forces
  653. Europe and Armed Forces Pacific.
  654. .. data:: us.us_states.COFA_STATES
  655. A tuple of choices of the postal abbreviations of the three
  656. independent nations which, under the Compact of Free Association,
  657. are served by the U.S. Postal Service: the Federated States of
  658. Micronesia, the Marshall Islands and Palau.
  659. .. data:: us.us_states.OBSOLETE_STATES
  660. A tuple of choices of obsolete U.S Postal Service state
  661. abbreviations: the former abbreviation for the Northern Mariana
  662. Islands, plus the Panama Canal Zone, the Philippines and the
  663. former Pacific trust territories.
  664. .. data:: us.us_states.STATE_CHOICES
  665. A tuple of choices of all postal abbreviations corresponding to U.S states or
  666. territories, and the District of Columbia..
  667. .. data:: us.us_states.USPS_CHOICES
  668. A tuple of choices of all postal abbreviations recognized by the
  669. U.S Postal Service (including all states and territories, the
  670. District of Columbia, armed forces "states" and independent
  671. nations serviced by USPS).
  672. Uruguay (``uy``)
  673. ================
  674. .. class:: uy.forms.UYCIField
  675. A field that validates Uruguayan 'Cedula de identidad' (CI) numbers.
  676. .. class:: uy.forms.UYDepartamentSelect
  677. A ``Select`` widget that uses a list of Uruguayan departaments as its
  678. choices.