Ticket #5676: mx-localflavor.diff

File mx-localflavor.diff, 2.2 KB (added by arien <regexbot@…>, 17 years ago)

mx localflavor

  • contrib/localflavor/mx/forms.py

     
     1"""MX-specific Form helpers."""
     2
     3from django.newforms.fields import Select
     4
     5class MXStateSelect(Select):
     6    """
     7    A Select widget that uses a list of Mexican states as its choices.
     8    """
     9    def __init__(self, attrs=None):
     10        from mx_states import STATE_CHOICES
     11        super(MXStateSelect, self).__init__(attrs, choices=STATE_CHOICES)
  • contrib/localflavor/mx/mx_states.py

     
     1# -*- coding: utf-8 -*-
     2
     3"""
     4A list of Mexican states for use as `choices` in a formfield.
     5
     6This exists in this standalone file so that it's only imported into memory
     7when explicitly needed.
     8"""
     9
     10from django.utils.translation import ugettext_lazy as _
     11
     12STATE_CHOICES = (
     13    ('AGU', _(u'Aguascalientes')),
     14    ('BCN', _(u'Baja California')),
     15    ('BCS', _(u'Baja California Sur')),
     16    ('CAM', _(u'Campeche')),
     17    ('CHH', _(u'Chihuahua')),
     18    ('CHP', _(u'Chiapas')),
     19    ('COA', _(u'Coahuila')),
     20    ('COL', _(u'Colima')),
     21    ('DIF', _(u'Distrito Federal')),
     22    ('DUR', _(u'Durango')),
     23    ('GRO', _(u'Guerrero')),
     24    ('GUA', _(u'Guanajuato')),
     25    ('HID', _(u'Hidalgo')),
     26    ('JAL', _(u'Jalisco')),
     27    ('MEX', _(u'Estado de México')),
     28    ('MIC', _(u'Michoacán')),
     29    ('MOR', _(u'Morelos')),
     30    ('NAY', _(u'Nayarit')),
     31    ('NLE', _(u'Nuevo León')),
     32    ('OAX', _(u'Oaxaca')),
     33    ('PUE', _(u'Puebla')),
     34    ('QUE', _(u'Querétaro')),
     35    ('ROO', _(u'Quintana Roo')),
     36    ('SIN', _(u'Sinaloa')),
     37    ('SLP', _(u'San Luis Potosí')),
     38    ('SON', _(u'Sonora')),
     39    ('TAB', _(u'Tabasco')),
     40    ('TAM', _(u'Tamaulipas')),
     41    ('TLA', _(u'Tlaxcala')),
     42    ('VER', _(u'Veracruz')),
     43    ('YUC', _(u'Yucatán')),
     44    ('ZAC', _(u'Zacatecas')),
     45)
Back to Top