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(*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.

Deprecated since version 1.4: Use the django-phonenumber-field library instead.

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

Normalized state names