Opened 8 years ago

Closed 6 years ago

#14308 closed New feature (invalid)

Adding some fields to the Mexican local flavor.

Reported by: Andrés Torres Owned by: nobody
Component: contrib.localflavor Version: 1.2
Severity: Normal Keywords: Mexican, Fields, localflavorsplit
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no


Fields like RFC, CURP and the ZIP Code are in this file attachment and in the code block here down.

MX-specific Form helpers

from django.forms.fields import RegexField

class MXRFCField(RegexField):
    A field that accepts a 'classic' MX RFC (Registro Federal de Contribuyentes).
    More info about this:
    def __init__(self, *args, **kwargs):
        super(MXRFCField, self).__init__(r'^[a-zA-Z]{3}[a-zA-Z\d]?(\d\d)(0[\d]{1}|1[0-2]{1})(0[\d]{1}|[1-2]{1}\d|3[0-1])[a-zA-Z\d]{3}$', *args, **kwargs)

    def clean(self, value):
        value = super(MXRFCField, self).clean(value)
        return value.upper()

class MXCURPField(RegexField):
    A field that accepts a 'classic' MX CURP (Clave Unica de Registro de Poblacion).
    More info about this:
    def __init__(self, *args, **kwargs):
        super(MXCURPField, self).__init__(r'^[a-zA-Z]{4}(\d\d)(0[\d]{1}|1[0-2]{1})(0[\d]{1}|[1-2]{1}\d|3[0-1])([hmHM]{1})[a-zA-Z]{5}\d{2}$', *args, **kwargs)

    def clean(self, value):
        value = super(MXCURPField, self).clean(value)
        return value.upper()

class MXZIPCodeField(RegexField):
    A field that accepts a 'classic' MX ZIP Code.
    More info about this:
    def __init__(self, *args, **kwargs):
        super(MXZIPCodeField, self).__init__(r'^(\d){5}$', *args, **kwargs)


Attachments (1) (1.5 KB) - added by Andrés Torres 8 years ago.
The same as above in the description.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by Andrés Torres

Attachment: added

The same as above in the description.

comment:1 Changed 8 years ago by Dougal Matthews

Has patch: set
Needs tests: set
Patch needs improvement: set

Presumably we will need tests to show that these work and documentation too.

It would be better to add a patch (svn diff) rather than a file as its easier for commiters to apply.

comment:2 Changed 8 years ago by Russell Keith-Magee

milestone: 1.3
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:4 Changed 7 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 7 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 6 years ago by Aymeric Augustin

Keywords: localflavorsplit added
Resolution: invalid
Status: newclosed

django.contrib.localflavor is now deprecated — see

A repository was created for each localflavor at (Replace with the country code.)

If you're still interested in this ticket, could you create a pull request on that repository?

Sorry for not resolving this issue earlier, and thanks for your input!

Note: See TracTickets for help on using tickets.
Back to Top