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', <django.utils.functional.__proxy__ object at 0x7f1e9e08a950>), ('02', <django.utils.functional.__proxy__ object at 0x7f1e9e08af90>), ('03', <django.utils.functional.__proxy__ object at 0x7f1e9e08a110>), ('04', <django.utils.functional.__proxy__ object at 0x7f1e9e08afd0>), ('05', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7bd0>), ('06', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7410>), ('07', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7690>), ('08', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7e90>), ('09', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7f50>), ('10', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7210>), ('11', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7dd0>), ('12', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7150>), ('13', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7590>), ('14', <django.utils.functional.__proxy__ object at 0x7f1e9dfc70d0>), ('15', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7e50>), ('16', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7d50>), ('17', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7750>), ('18', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7310>), ('19', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7ed0>), ('20', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7850>), ('21', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7950>), ('22', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7550>), ('23', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7d10>), ('24', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7f90>), ('25', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7290>), ('26', <django.utils.functional.__proxy__ object at 0x7f1e9dfc73d0>), ('27', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7350>), ('28', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7910>), ('29', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7fd0>), ('30', <django.utils.functional.__proxy__ object at 0x7f1e9dfc7790>), ('31', <django.utils.functional.__proxy__ object at 0x7f1e9df309d0>), ('32', <django.utils.functional.__proxy__ object at 0x7f1e9df30e90>), ('33', <django.utils.functional.__proxy__ object at 0x7f1e9df30390>), ('34', <django.utils.functional.__proxy__ object at 0x7f1e9df308d0>), ('35', <django.utils.functional.__proxy__ object at 0x7f1e9df30710>), ('36', <django.utils.functional.__proxy__ object at 0x7f1e9df30850>), ('37', <django.utils.functional.__proxy__ object at 0x7f1e9df30c10>), ('38', <django.utils.functional.__proxy__ object at 0x7f1e9df30cd0>), ('39', <django.utils.functional.__proxy__ object at 0x7f1e9df30b10>), ('40', <django.utils.functional.__proxy__ object at 0x7f1e9df30790>), ('41', <django.utils.functional.__proxy__ object at 0x7f1e9df30a10>), ('42', <django.utils.functional.__proxy__ object at 0x7f1e9df307d0>), ('43', <django.utils.functional.__proxy__ object at 0x7f1e9df30a90>), ('44', <django.utils.functional.__proxy__ object at 0x7f1e9df30d90>), ('45', <django.utils.functional.__proxy__ object at 0x7f1e9df30150>), ('46', <django.utils.functional.__proxy__ object at 0x7f1e9df30c50>), ('47', <django.utils.functional.__proxy__ object at 0x7f1e9df30310>), ('48', <django.utils.functional.__proxy__ object at 0x7f1e9df30910>), ('49', <django.utils.functional.__proxy__ object at 0x7f1e9df30c90>), ('50', <django.utils.functional.__proxy__ object at 0x7f1e9df30650>), ('51', <django.utils.functional.__proxy__ object at 0x7f1e9df303d0>), ('52', <django.utils.functional.__proxy__ object at 0x7f1e9df30250>))

An alphabetical list of provinces

localflavor.es.es_regions.REGION_CHOICES = (('AN', <django.utils.functional.__proxy__ object at 0x7f1e9df306d0>), ('AR', <django.utils.functional.__proxy__ object at 0x7f1e9df30550>), ('O', <django.utils.functional.__proxy__ object at 0x7f1e9df30d10>), ('IB', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf550>), ('PV', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf710>), ('CN', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf2d0>), ('S', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf0d0>), ('CM', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf1d0>), ('CL', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf390>), ('CT', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf910>), ('EX', <django.utils.functional.__proxy__ object at 0x7f1e9dfafb50>), ('GA', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf3d0>), ('LO', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf150>), ('M', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf110>), ('MU', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf7d0>), ('NA', <django.utils.functional.__proxy__ object at 0x7f1e9dfafa50>), ('VC', <django.utils.functional.__proxy__ object at 0x7f1e9dfaffd0>), ('CE', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf290>), ('ML', <django.utils.functional.__proxy__ object at 0x7f1e9dfaf350>))

An alphabetical list of regions