Mexico (mx)

Forms

Mexican-specific form helpers.

localflavor.mx.forms.CURP_INCONVENIENT_WORDS = ['BACA', 'BAKA', 'BUEI', 'BUEY', 'CACA', 'CACO', 'CAGA', 'CAGO', 'CAKA', 'CAKO', 'COGE', 'COGI', 'COJA', 'COJE', 'COJI', 'COJO', 'COLA', 'CULO', 'FALO', 'FETO', 'GETA', 'GUEI', 'GUEY', 'JETA', 'JOTO', 'KACA', 'KACO', 'KAGA', 'KAGO', 'KAKA', 'KAKO', 'KOGE', 'KOGI', 'KOJA', 'KOJE', 'KOJI', 'KOJO', 'KOLA', 'KULO', 'LILO', 'LOCA', 'LOCO', 'LOKA', 'LOKO', 'MAME', 'MAMO', 'MEAR', 'MEAS', 'MEON', 'MIAR', 'MION', 'MOCO', 'MOKO', 'MULA', 'MULO', 'NACA', 'NACO', 'PEDA', 'PEDO', 'PENE', 'PIPI', 'PITO', 'POPO', 'PUTA', 'PUTO', 'QULO', 'RATA', 'ROBA', 'ROBE', 'ROBO', 'RUIN', 'SENO', 'TETA', 'VAGA', 'VAGO', 'VAKA', 'VUEI', 'VUEY', 'WUEI', 'WUEY']

This is the list of inconvenient words according to the Anexo 2 of the document described in the next link: http://portal.veracruz.gob.mx/pls/portal/url/ITEM/444112558A57C6E0E040A8C02E00695C

class localflavor.mx.forms.MXCLABEField(min_length=18, max_length=18, **kwargs)[source]

This field validates a CLABE (Clave Bancaria Estandarizada).

A CLABE is a 18-digits long number. The first 6 digits denote bank and branch number. The remaining 12 digits denote an account number, plus a verifying digit.

More info: https://en.wikipedia.org/wiki/CLABE

New in version 1.4.

clean(value)[source]

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

class localflavor.mx.forms.MXCURPField(min_length=18, max_length=18, **kwargs)[source]

A field that validates a Mexican Clave Única de Registro de Población.

The CURP is integrated by a juxtaposition of characters following the next pattern:

Index Format Accepted Characters
1 X Any letter
2 X Any vowel
3-4 XX Any letter
5-10 YYMMDD Any valid date
11 X Either H or M, depending on the person’s gender
12-13 XX Any valid acronym for a state in Mexico
14-16 XXX Any consonant
17 X Any number between 0 and 9 or any letter
18 X Any number between 0 and 9
More info about this:
http://www.condusef.gob.mx/index.php/clave-unica-de-registro-de-poblacion-curp
clean(value)[source]

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

class localflavor.mx.forms.MXRFCField(min_length=12, max_length=13, **kwargs)[source]

A form field that validates a Mexican Registro Federal de Contribuyentes.

Validates either Persona física or Persona moral. The Persona física RFC string is integrated by a juxtaposition of characters following the next pattern:

Index Format Accepted Characters
1 X Any letter
2 X Any vowel
3-4 XX Any letter
5-10 YYMMDD Any valid date
11-12 XX Any letter or number between 0 and 9
13 X Any digit between 0 and 9 or the letter A

The Persona moral RFC string is integrated by a juxtaposition of characters following the next pattern:

Index Format Accepted Characters
1-3 XXX Any letter including & and Ñ chars
4-9 YYMMDD Any valid date
10-11 XX Any letter or number between 0 and 9
12 X Any number between 0 and 9 or the letter A
More info about this:
http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
clean(value)[source]

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

class localflavor.mx.forms.MXSocialSecurityNumberField(min_length=11, max_length=11, **kwargs)[source]

A field that validates a Mexican Social Security Number.

The Social Security Number is integrated by a juxtaposition of digits following the next pattern:

Index Required numbers
1-2 The number of the branch office where the Social Security Number was designated.
3-4 The year of inscription to the Social Security.
5-6 The year of birth of the Social Security Number owner.
7-10 The progressive number of procedure for the IMSS. (This digit is provided exclusively by the Institute as it regards the Folio number of such procedure).
11 The verification digit.
clean(value)[source]

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

class localflavor.mx.forms.MXStateSelect(attrs=None)[source]

A Select widget that uses a list of Mexican states as its choices.

class localflavor.mx.forms.MXZipCodeField(**kwargs)[source]

A form field that accepts a Mexican Zip Code.

More info about this:
http://en.wikipedia.org/wiki/List_of_postal_codes_in_Mexico
localflavor.mx.forms.RFC_INCONVENIENT_WORDS = ['BUEI', 'BUEY', 'CACA', 'CACO', 'CAGA', 'CAGO', 'CAKA', 'CAKO', 'COGE', 'COJA', 'COJE', 'COJI', 'COJO', 'CULO', 'FETO', 'GUEY', 'JOTO', 'KACA', 'KACO', 'KAGA', 'KAGO', 'KOGE', 'KOJO', 'KAKA', 'KULO', 'MAME', 'MAMO', 'MEAR', 'MEAS', 'MEON', 'MION', 'MOCO', 'MULA', 'PEDA', 'PEDO', 'PENE', 'PUTA', 'PUTO', 'QULO', 'RATA', 'RUIN']

This is the list of inconvenient words according to the Anexo IV of the document described in the next link: http://www.sisi.org.mx/jspsi/documentos/2005/seguimiento/06101/0610100162005_065.doc

Models

class localflavor.mx.models.MXCLABEField(*args, **kwargs)[source]

A model field that forms represent as a forms.MXCURPField field and stores the value of a valid Mexican CLABE.

New in version 1.4.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.mx.models.MXCURPField(*args, **kwargs)[source]

A model field that forms represent as a forms.MXCURPField field and stores the value of a valid Mexican CURP.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.mx.models.MXRFCField(*args, **kwargs)[source]

A model field that forms represent as a forms.MXRFCField field and stores the value of a valid Mexican RFC.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.mx.models.MXSocialSecurityNumberField(*args, **kwargs)[source]

A model field that forms represent as a forms.MXSocialSecurityNumberField field.

It stores the value of a valid Mexican Social Security Number.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.mx.models.MXStateField(*args, **kwargs)[source]

A model field that stores the three or four letter Mexican state abbreviation in the database.

deconstruct()[source]

Return enough information to recreate the field as a 4-tuple:

  • The name of the field on the model, if contribute_to_class() has been run.
  • The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.
  • A list of positional arguments.
  • A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):

  • None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
  • UUID
  • datetime.datetime (naive), datetime.date
  • top-level classes, top-level functions - will be referenced by their full import path
  • Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.

There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.

class localflavor.mx.models.MXZipCodeField(*args, **kwargs)[source]

A model field that forms represent as a forms.MXZipCodeField field and stores the five-digit Mexican zip code.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

Data

localflavor.mx.mx_states.STATE_CHOICES = (('AGU', 'Aguascalientes'), ('BCN', 'Baja California'), ('BCS', 'Baja California Sur'), ('CAM', 'Campeche'), ('CDMX', 'Ciudad de México'), ('CHH', 'Chihuahua'), ('CHP', 'Chiapas'), ('COA', 'Coahuila'), ('COL', 'Colima'), ('DUR', 'Durango'), ('GRO', 'Guerrero'), ('GUA', 'Guanajuato'), ('HID', 'Hidalgo'), ('JAL', 'Jalisco'), ('MEX', 'Estado de México'), ('MIC', 'Michoacán'), ('MOR', 'Morelos'), ('NAY', 'Nayarit'), ('NLE', 'Nuevo León'), ('OAX', 'Oaxaca'), ('PUE', 'Puebla'), ('QUE', 'Querétaro'), ('ROO', 'Quintana Roo'), ('SIN', 'Sinaloa'), ('SLP', 'San Luis Potosí'), ('SON', 'Sonora'), ('TAB', 'Tabasco'), ('TAM', 'Tamaulipas'), ('TLA', 'Tlaxcala'), ('VER', 'Veracruz'), ('YUC', 'Yucatán'), ('ZAC', 'Zacatecas'))

All 31 states, plus the Ciudad de México.