Spain (es)

Forms

Spanish-specific Form helpers.

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

A form field that validates its input as a Spanish bank account or CCC (Codigo Cuenta Cliente).

Spanish CCC is in format EEEE-OOOO-CC-AAAAAAAAAA where:

E = entity O = office C = checksum A = account

It’s also valid to use a space as delimiter, or to use no delimiter.

First checksum digit validates entity and office, and last one validates account. Validation is done multiplying every digit of 10 digit value (with leading 0 if necessary) by number in its position in string 1, 2, 4, 8, 5, 10, 9, 7, 3, 6. Sum resulting numbers and extract it from 11. Result is checksum except when 10 then is 1, or when 11 then is 0.

TODO: allow IBAN validation too

class localflavor.es.forms.ESIdentityCardNumberField(only_nif=False, max_length=None, min_length=None, *args, **kwargs)[source]

Spanish NIF/NIE/CIF (Fiscal Identification Number) code.

Validates three diferent formats:

NIF (individuals): 12345678A CIF (companies): A12345678 NIE (foreigners): X12345678A

according to a couple of simple checksum algorithms.

Value can include a space or hyphen separator between number and letters. Number length is not checked for NIF (or NIE), old values start with a 1, and future values can contain digits greater than 8. The CIF control digit can be a number or a letter depending on company type. Algorithm is not public, and different authors have different opinions on which ones allows letters, so both validations are assumed true for all types.

http://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal

Changed in version 1.1.

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

A form field that validates its input as a Spanish phone number.

Information numbers are ommited.

Spanish phone numbers are nine digit numbers, where first digit is 6 (for cell phones), 8 (for special phones), or 9 (for landlines and special phones)

TODO: accept and strip characters like dot, hyphen... in phone number

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

A form field that validates its input as a spanish postal code.

Spanish postal code is a five digits string, with two first digits between 01 and 52, assigned to provinces code.

class localflavor.es.forms.ESProvinceSelect(attrs=None)[source]

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

class localflavor.es.forms.ESRegionSelect(attrs=None)[source]

A Select widget that uses a list of spanish regions as its choices.

Data

localflavor.es.es_provinces.PROVINCE_CHOICES = (('01', 'Araba'), ('02', 'Albacete'), ('03', 'Alacant'), ('04', 'Almeria'), ('05', 'Avila'), ('06', 'Badajoz'), ('07', 'Illes Balears'), ('08', 'Barcelona'), ('09', 'Burgos'), ('10', 'Caceres'), ('11', 'Cadiz'), ('12', 'Castello'), ('13', 'Ciudad Real'), ('14', 'Cordoba'), ('15', 'A Coruna'), ('16', 'Cuenca'), ('17', 'Girona'), ('18', 'Granada'), ('19', 'Guadalajara'), ('20', 'Guipuzkoa'), ('21', 'Huelva'), ('22', 'Huesca'), ('23', 'Jaen'), ('24', 'Leon'), ('25', 'Lleida'), ('26', 'La Rioja'), ('27', 'Lugo'), ('28', 'Madrid'), ('29', 'Malaga'), ('30', 'Murcia'), ('31', 'Navarre'), ('32', 'Ourense'), ('33', 'Asturias'), ('34', 'Palencia'), ('35', 'Las Palmas'), ('36', 'Pontevedra'), ('37', 'Salamanca'), ('38', 'Santa Cruz de Tenerife'), ('39', 'Cantabria'), ('40', 'Segovia'), ('41', 'Seville'), ('42', 'Soria'), ('43', 'Tarragona'), ('44', 'Teruel'), ('45', 'Toledo'), ('46', 'Valencia'), ('47', 'Valladolid'), ('48', 'Bizkaia'), ('49', 'Zamora'), ('50', 'Zaragoza'), ('51', 'Ceuta'), ('52', 'Melilla'))

An alphabetical list of provinces

localflavor.es.es_regions.REGION_CHOICES = (('AN', 'Andalusia'), ('AR', 'Aragon'), ('O', 'Principality of Asturias'), ('IB', 'Balearic Islands'), ('PV', 'Basque Country'), ('CN', 'Canary Islands'), ('S', 'Cantabria'), ('CM', 'Castile-La Mancha'), ('CL', 'Castile and Leon'), ('CT', 'Catalonia'), ('EX', 'Extremadura'), ('GA', 'Galicia'), ('LO', 'La Rioja'), ('M', 'Madrid'), ('MU', 'Region of Murcia'), ('NA', 'Foral Community of Navarre'), ('VC', 'Valencian Community'), ('CE', 'Autonomous city of Ceuta'), ('ML', 'Autonomous city of Mellila'))

An alphabetical list of regions