Iran (ir)

Forms

Iranian-specific form helpers.

class localflavor.ir.forms.IRIDNumberField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]

A form field that validates its input as an Iranian identification number.

Valid form is per the Iranian ID specification.

Persian documentation :

http://www.aliarash.com/article/codemeli/codemeli.htm

There isn’t good English documentation available for the Iranian identification number. Non-Persian speakers will need to use an online translation service to read this documentation.

New in version 2.2.

clean(value)[source]

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

class localflavor.ir.forms.IRPostalCodeField(**kwargs)[source]

A form field that validates its input as an Iran postal code.

Valid form is XXXXXXXXXX where X represents integer.

Validate code:
  • don’t use 0 in first 5 digit
  • don’t use 2 in postal code
  • First 4 digit is not the same
  • The 5th digit cannot be 5
  • all digits aren’t the same

New in version 2.2.

clean(value)[source]

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

class localflavor.ir.forms.IRProvinceSelect(attrs=None)[source]

A Select widget that uses a list of Iran provinces cities as its choices.

New in version 2.2.

localflavor.ir.ir_provinces.PROVINCE_CHOICES = (('AL', 'Alborz'), ('AR', 'Ardabil'), ('AE', 'Azerbaijan East'), ('AW', 'Azerbaijan Wast'), ('BU', 'Bushehr'), ('CM', 'Chahar Mahaal and Bakhtiari'), ('FA', 'Fars'), ('GI', 'Gilan'), ('GO', 'Golestan'), ('HA', 'Hamadan'), ('HO', 'Hormozgan'), ('IL', 'Ilam'), ('IS', 'Isfahan'), ('KE', 'Kerman'), ('KM', 'Kermanshah'), ('KN', 'Khorasan North'), ('KR', 'Khorasan Razavi'), ('KS', 'Khorasan South'), ('KH', 'Khuzestan'), ('KB', 'Kohgiluyeh and Boyer-Ahmad'), ('KU', 'Kurdistan'), ('LO', 'Lorestan'), ('MA', 'Markazi'), ('MZ', 'Mazandaran'), ('QA', 'Qazvin'), ('QO', 'Qom'), ('SE', 'Semnan'), ('SB', 'Sistan and Baluchestan'), ('TH', 'Tehran'), ('YZ', 'Yazd'), ('ZN', 'Zanjan'))

A list of Iran provinces and autonomous cities as choices in a formfield. From https://en.wikipedia.org/wiki/Provinces_of_Iran