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

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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(*args, **kwargs)[source]

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

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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

Normalized state names