India (in)

Forms

India-specific Form helpers.

class localflavor.in_.forms.INAadhaarNumberField(required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=[], localize=False, disabled=False, label_suffix=None)[source]

A form field for Aadhaar number issued by Unique Identification Authority of India (UIDAI).

Checks the following rules to determine whether the number is valid:

  • Conforms to the XXXX XXXX XXXX format.
  • No group consists entirely of zeroes.

Important information:

  • Aadhaar number is a proof of identity but not of citizenship.
  • Aadhaar number is issued to every resident of India including foreign citizens.
  • Aadhaar number is not mandatory.

More information can be found at http://uidai.gov.in/what-is-aadhaar-number.html

class localflavor.in_.forms.INPhoneNumberField(max_length=None, min_length=None, strip=True, *args, **kwargs)[source]

INPhoneNumberField validates that the data is a valid Indian phone number, including the STD code. It’s normalised to 0XXX-XXXXXXX or 0XXX XXXXXXX format. The first string is the STD code which is a ‘0’ followed by 2-4 digits. The second string is 8 digits if the STD code is 3 digits, 7 digits if the STD code is 4 digits and 6 digits if the STD code is 5 digits. The second string will start with numbers between 1 and 6. The separator is either a space or a hyphen.

class localflavor.in_.forms.INStateField(required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=[], localize=False, disabled=False, label_suffix=None)[source]

A form field that validates its input is a Indian state name or abbreviation. It normalizes the input to the standard two-letter vehicle registration abbreviation for the given state or union territory

Changed in version 1.1: Added Telangana to list of states. More details at https://en.wikipedia.org/wiki/Telangana#Bifurcation_of_Andhra_Pradesh

class localflavor.in_.forms.INStateSelect(attrs=None)[source]

A Select widget that uses a list of Indian states/territories as its choices.

Changed in version 1.1: Added Telangana to list of states. More details at https://en.wikipedia.org/wiki/Telangana#Bifurcation_of_Andhra_Pradesh

class localflavor.in_.forms.INZipCodeField(max_length=None, min_length=None, *args, **kwargs)[source]

A form field that validates input as an Indian zip code, with the format XXXXXXX.

Data

localflavor.in_.in_states.STATE_CHOICES = (('KA', 'Karnataka'), ('AP', 'Andhra Pradesh'), ('KL', 'Kerala'), ('TN', 'Tamil Nadu'), ('MH', 'Maharashtra'), ('UP', 'Uttar Pradesh'), ('GA', 'Goa'), ('GJ', 'Gujarat'), ('RJ', 'Rajasthan'), ('HP', 'Himachal Pradesh'), ('JK', 'Jammu and Kashmir'), ('TG', 'Telangana'), ('AR', 'Arunachal Pradesh'), ('AS', 'Assam'), ('BR', 'Bihar'), ('CG', 'Chattisgarh'), ('HR', 'Haryana'), ('JH', 'Jharkhand'), ('MP', 'Madhya Pradesh'), ('MN', 'Manipur'), ('ML', 'Meghalaya'), ('MZ', 'Mizoram'), ('NL', 'Nagaland'), ('OR', 'Orissa'), ('PB', 'Punjab'), ('SK', 'Sikkim'), ('TR', 'Tripura'), ('UA', 'Uttarakhand'), ('WB', 'West Bengal'), ('AN', 'Andaman and Nicobar'), ('CH', 'Chandigarh'), ('DN', 'Dadra and Nagar Haveli'), ('DD', 'Daman and Diu'), ('DL', 'Delhi'), ('LD', 'Lakshadweep'), ('PY', 'Pondicherry'))

A list of states

localflavor.in_.in_states.STATES_NORMALIZED = {'andaman and nicobar': 'AN', 'ld': 'LD', 'telangana': 'TG', 'ml': 'ML', 'or': 'OR', 'jharkhand': 'JH', 'uttarakhand': 'UA', 'haryana': 'HR', 'andra pradesh': 'AP', 'hr': 'HR', 'mp': 'MP', 'nl': 'NL', 'tripura': 'TR', 'mn': 'MN', 'bengal': 'WB', 'pondicherry': 'PY', 'goa': 'GA', 'tr': 'TR', 'assam': 'AS', 'dn': 'DN', 'uttar pradesh': 'UP', 'madhya pradesh': 'MP', 'ga': 'GA', 'lakshadweep': 'LD', 'tamil nadu': 'TN', 'cg': 'CG', 'nagaland': 'NL', 'chandigarh': 'CH', 'tamilnad': 'TN', 'ap': 'AP', 'andrapradesh': 'AP', 'gujarat': 'GJ', 'sikkim': 'SK', 'jk': 'JK', 'orissa': 'OR', 'maharashtra': 'MH', 'arunachal pradesh': 'AR', 'br': 'BR', 'pb': 'PB', 'an': 'AN', 'andhra pradesh': 'AP', 'mh': 'MH', 'andhrapradesh': 'AP', 'tn': 'TN', 'rajasthan': 'RJ', 'himachal pradesh': 'HP', 'westbengal': 'WB', 'bihar': 'BR', 'tamilnadu': 'TN', 'as': 'AS', 'gj': 'GJ', 'karnatka': 'KA', 'kl': 'KL', 'odisa': 'OR', 'delhi': 'DL', 'meghalaya': 'ML', 'orisa': 'OR', 'mizoram': 'MZ', 'punjab': 'PB', 'rajastan': 'RJ', 'ua': 'UA', 'west bengal': 'WB', 'manipur': 'MN', 'tg': 'TG', 'ch': 'CH', 'up': 'UP', 'ka': 'KA', 'karnataka': 'KA', 'jh': 'JH', 'daman and diu': 'DD', 'jammu and kashmir': 'JK', 'mizo': 'MZ', 'chattisgarh': 'CG', 'ar': 'AR', 'rj': 'RJ', 'maharastra': 'MH', 'hp': 'HP', 'dl': 'DL', 'py': 'PY', 'mz': 'MZ', 'sk': 'SK', 'dadra and nagar haveli': 'DN', 'kerala': 'KL', 'wb': 'WB', 'dd': 'DD'}

Normalized state names