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.INPANCardNumberFormField(**kwargs)[source]

A form field that accepts Indian Permanent account number(PAN) Card Number.

Rules:
  1. It should be ten characters long.
  2. The first three characters must be any upper case alphabets.
  3. The fourth character of PAN must be one of the following characters.
    A — Association of persons (AOP) B — Body of individuals (BOI) C — Company F — Firm G — Government H — HUF (Hindu undivided family) L — Local authority J — Artificial juridical person P — Person (Individual) T — Trust (AOP)
  4. The fifth character is first letter of lastname of the PAN Card holder in case of Individual
    or the first letter of first name in case of non-individual.
  5. The next four-characters must be any number from 0000 to 9999.
  6. The last(tenth) character which is a check-sum character must be any upper case alphabet.
Note:
  1. The validation of the fifth character must be done by the developer themselves,
    as this validation is out of the scope of this project.
  2. The validation for the last digit (i.e check-sum character) is not available
    in public domain, hence it is not implemented.
More Information at:
  1. https://en.wikipedia.org/wiki/Permanent_account_number
  2. https://www.incometaxindia.gov.in/tutorials/1.permanent%20account%20number%20(pan).pdf

New in version 4.0.

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

Changed in version 3.1: Updated Indian states and union territories names and code as per iso 3166 (https://www.iso.org/obp/ui/#iso:code:3166:IN)

class localflavor.in_.forms.INZipCodeField(**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'), ('TG', 'Telangana'), ('AR', 'Arunachal Pradesh'), ('AS', 'Assam'), ('BR', 'Bihar'), ('CT', 'Chhattisgarh'), ('HR', 'Haryana'), ('JH', 'Jharkhand'), ('MP', 'Madhya Pradesh'), ('MN', 'Manipur'), ('ML', 'Meghalaya'), ('MZ', 'Mizoram'), ('NL', 'Nagaland'), ('OR', 'Odisha'), ('PB', 'Punjab'), ('SK', 'Sikkim'), ('TR', 'Tripura'), ('UT', 'Uttarakhand'), ('WB', 'West Bengal'), ('AN', 'Andaman and Nicobar Islands'), ('CH', 'Chandigarh'), ('DH', 'Dadra and Nagar Haveli and Daman and Diu'), ('DL', 'Delhi'), ('JK', 'Jammu and Kashmir'), ('LD', 'Lakshadweep'), ('LA', 'Ladakh'), ('PY', 'Puducherry'))

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', 'chhattisgarh': '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