Index: django/contrib/localflavor/ni/ni_departaments.py
===================================================================
--- django/contrib/localflavor/ni/ni_departaments.py	(revisión: 0)
+++ django/contrib/localflavor/ni/ni_departaments.py	(revisión: 0)
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+""" 
+An alphabetical list of departaments for use as `choices` 
+in a formfield., 
+
+Source: http://es.wikipedia.org/wiki/Departamentos_de_Nicaragua 
+
+This exists in this standalone file so that it's only imported into memory 
+when explicitly needed. 
+""" 
+from django.utils.translation import ugettext_lazy as _
+
+DEPARTAMENT_CHOICES = ( 
+    ('BO', _(u'Boaco')), 
+    ('CZ', _(u'Carazo')), 
+    ('CH', _(u'Chinandega')), 
+    ('CT', _(u'Chontales')), 
+    ('ES', _(u'Estelí')), 
+    ('GR', _(u'Granada')), 
+    ('JI', _(u'Jinotega')), 
+    ('LE', _(u'León')), 
+    ('MZ', _(u'Madriz')), 
+    ('M', _(u'Managua')), 
+    ('MY', _(u'Masaya')), 
+    ('MT', _(u'Matagalpa')), 
+    ('NS', _(u'Nueva Segovia')), 
+    ('RI', _(u'Rivas')), 
+    ('RS', _(u'Río San Juan')), 
+    ('RAAN', _(u'Región Autónoma del Atlántico Norte(RAAN)')), 
+    ('RAAS', _(u'Región Autónoma del Atlántico Sur(RAAS)')), 
+)
+
Index: django/contrib/localflavor/ni/__init__.py
===================================================================
Index: django/contrib/localflavor/ni/forms.py
===================================================================
--- django/contrib/localflavor/ni/forms.py	(revisión: 0)
+++ django/contrib/localflavor/ni/forms.py	(revisión: 0)
@@ -0,0 +1,62 @@
+"""
+Nicaragua-specific Form helpers
+"""
+
+from django.forms import ValidationError
+from django.forms.fields import  RegexField, ChoiceField, EMPTY_VALUES
+from django.forms.util import smart_unicode
+from django.utils.translation import ugettext_lazy as _
+import re
+
+
+class NIPhoneNumberField(RegexField):
+    """
+    Nicaraguan phone number field. 
+    NOTE: Nicaragua will add another digit from April 1st 2009.
+    """
+    default_error_messages = {
+        'invalid': u'Phone numbers must be in the format  XXX-XXXX or XXXXXXX.',
+    }
+
+    def __init__(self, *args, **kwargs):
+        super(NIPhoneNumberField, self).__init__(r'^\d{3}-\d{4}|^\d{7}$',
+                max_length = None, min_length = None, *args, **kwargs)
+
+    def clean(self, value):
+        """
+        Validates the input and returns a string with only numbers.
+        Returns an empty string for empty values
+        """
+        v = super(NIPhoneNumberField, self).clean(value)
+        return v.replace('-', '')
+    
+class NIDepartamentSelect(ChoiceField):
+    """
+    A Select widget that uses a list of Nicaraguan departaments.
+    """
+    def __init__(self):
+        from django.contrib.localflavor.ni.ni_departaments import DEPARTAMENT_CHOICES # relative import
+        super(NIDepartamentSelect, self).__init__(choices=DEPARTAMENT_CHOICES)
+
+class NICedulaNumberField(RegexField):
+    """
+    Cedula number(cedula is the identification document to
+    vote and make legal stuff in Nicaragua.
+    
+    The format is 999-999999-9999A where 9 is a number and A is a letter. 
+    """
+    default_error_messages = {
+        'invalid': _('Enter a valid Cedula number in XXX-XXXXXX-XXXXX format.'),
+    }
+    
+    def __init__(self, *args, **kwargs):
+        super(NICedulaNumberField, self).__init__(r'^(\d{3})-(\d{6})-(\d{4}[a-zA-z])$',
+                max_length = None, min_length = None, *args, **kwargs)
+
+
+    def clean(self, value):
+        value = super(NICedulaNumberField, self).clean(value)
+        if value in EMPTY_VALUES:
+            return u''
+        else:
+            return value
Index: tests/regressiontests/forms/localflavor/ni.py
===================================================================
--- tests/regressiontests/forms/localflavor/ni.py	(revisión: 0)
+++ tests/regressiontests/forms/localflavor/ni.py	(revisión: 0)
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+# Test for the contrib/localflavor/ NI form fields
+
+tests = """
+#NIPhoneNumberField ########################
+
+A form field that validates Nicaraguan Phone Number validation.
+>>> from django.contrib.localflavor.ni.forms import NIPhoneNumberField
+>>> phone = NIPhoneNumberField()
+>>> phone.clean('233-3023')
+u'2333023'                 
+>>> phone.clean('2333023')
+u'2333023'                
+>>> phone.clean('2333-023')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 30, in clean
+    v = super(NIPhoneNumberField, self).clean(value)                                               
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean               
+    raise ValidationError(self.error_messages['invalid'])                                          
+django.forms.util.ValidationError: [u'Phone numbers must be in the format  XXX-XXXX or XXXXXXX.']  
+>>> phone.clean('a33-3023')                                                                      
+Traceback (most recent call last):                                                               
+  File "<stdin>", line 1, in <module>                                                            
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 30, in clean
+    v = super(NIPhoneNumberField, self).clean(value)                                               
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean               
+    raise ValidationError(self.error_messages['invalid'])                                          
+django.forms.util.ValidationError: [u'Phone numbers must be in the format  XXX-XXXX or XXXXXXX.']  
+>>> phone.clean('23334023')                                                                     
+Traceback (most recent call last):                                                              
+  File "<stdin>", line 1, in <module>                                                           
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 30, in clean
+    v = super(NIPhoneNumberField, self).clean(value)                                               
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean
+    raise ValidationError(self.error_messages['invalid'])
+django.forms.util.ValidationError: [u'Phone numbers must be in the format  XXX-XXXX or XXXXXXX.']
+>>> phone.clean('')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 30, in clean
+    v = super(NIPhoneNumberField, self).clean(value)
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 414, in clean
+    value = super(RegexField, self).clean(value)
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 148, in clean
+    super(CharField, self).clean(value)
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 119, in clean
+    raise ValidationError(self.error_messages['required'])
+django.forms.util.ValidationError>>>
+>>> phone = NIPhoneNumberField(required = False)
+>>> phone.clean('')
+u''
+>>> phone.clean(None)
+u''
+
+
+#NICedulaNumberField ##########
+
+Personal identication number in Nicaragua. In format 999-999999-9999A where 9 is a number an A a letter
+
+>>> from django.contrib.localflavor.ni.forms import NICedulaNumberField
+>>> c = NICedulaNumberField()                                          
+>>> c.clean('001-090934-0002A')
+u'001-090934-0002A'            
+>>> c.clean('001-090934-00023')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 58, in clean
+    value = super(NICedulaNumberField, self).clean(value)                                          
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean               
+    raise ValidationError(self.error_messages['invalid'])                                          
+django.forms.util.ValidationError>>> c.clean('001-0909A4-0002A')                                 
+Traceback (most recent call last):                                                               
+  File "<stdin>", line 1, in <module>                                                            
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 58, in clean
+    value = super(NICedulaNumberField, self).clean(value)                                          
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean               
+    raise ValidationError(self.error_messages['invalid'])                                          
+django.forms.util.ValidationError>>> c.clean('001090994-0002A')                                  
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 58, in clean
+    value = super(NICedulaNumberField, self).clean(value)
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean
+    raise ValidationError(self.error_messages['invalid'])
+django.forms.util.ValidationError
+>>> c.clean('0a1-090934-0002A')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/contrib/localflavor/ni/forms.py", line 58, in clean
+    value = super(NICedulaNumberField, self).clean(value)
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 418, in clean
+    raise ValidationError(self.error_messages['invalid'])
+django.forms.util.ValidationError
+>>> c.clean('001-090994-0002a')
+u'001-090994-0002a'
+
+# NIDepartamentSelect #############
+
+A choice field with the 15 departaments and 2 autonomic regions in Nicaragua.
+
+>>> 
+>>> d = NIDepartamentSelect()
+>>> d._get_choices()         
+[('BO', <django.utils.functional.__proxy__ object at 0x7f4537003750>), ('CZ', <django.utils.functional.__proxy__ object at 0x7f4537003990>), ('CH', <django.utils.functional.__proxy__ object at 0x7f4537003410>), ('CT', <django.utils.functional.__proxy__ object at 0x7f4537003450>), ('ES', <django.utils.functional.__proxy__ object at 0x7f4537003490>), ('GR', <django.utils.functional.__proxy__ object at 0x7f45370035d0>), ('JI', <django.utils.functional.__proxy__ object at 0x7f4537003710>), ('LE', <django.utils.functional.__proxy__ object at 0x7f4537003890>), ('MZ', <django.utils.functional.__proxy__ object at 0x7f4537003910>), ('M', <django.utils.functional.__proxy__ object at 0x7f45365bfd50>), ('MY', <django.utils.functional.__proxy__ object at 0x7f45365bfdd0>), ('MT', <django.utils.functional.__proxy__ object at 0x7f45365bfe50>), ('NS', <django.utils.functional.__proxy__ object at 0x7f45365bfed0>), ('RI', <django.utils.functional.__proxy__ object at 0x7f45365bff10>), ('RS', <django.utils.functional.__proxy__ object at 0x7f45365bff90>), ('RAAN', <django.utils.functional.__proxy__ object at 0x7f453613e050>), ('RAAS', <django.utils.functional.__proxy__ object at 0x7f453613e0d0>)]                                                                   
+>>> d.clean('M')
+u'M' 
+>>> d.clean('FOO')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib/python2.5/site-packages/django/forms/fields.py", line 649, in clean
+    raise ValidationError(self.error_messages['invalid_choice'] % {'value': value})
+django.forms.util.ValidationError: [u'Escoja una opci\xf3n v\xe1lida. FOO no es una de las opciones disponibles.']
+>>> d.valid_value('M')
+True
+>>> d.valid_value('FOO')
+False
+"""
+
Index: docs/ref/contrib/localflavor.txt
===================================================================
--- docs/ref/contrib/localflavor.txt	(revisión: 9814)
+++ docs/ref/contrib/localflavor.txt	(copia de trabajo)
@@ -53,6 +53,7 @@
     * Japan_
     * Mexico_
     * `The Netherlands`_
+    * Nicaragua_
     * Norway_
     * Peru_
     * Poland_
@@ -92,6 +93,7 @@
 .. _Italy: `Italy (it)`_
 .. _Japan: `Japan (jp)`_
 .. _Mexico: `Mexico (mx)`_
+.. _Nicaragua: `Nicaragua (ni)`_
 .. _Norway: `Norway (no)`_
 .. _Peru: `Peru (pe)`_
 .. _Poland: `Poland (pl)`_
@@ -390,6 +392,24 @@
 
     A ``Select`` widget that uses a list of Mexican states as its choices.
 
+Nicaragua (``ni``)
+===============
+
+.. class:: ni.forms.NIDepartamentSelect
+
+    A ``ChoiceField`` that uses a displays of Nicaraguan departaments and regions.
+
+.. class:: ni.forms.NICedulaNumberField
+
+    A form field that validates input as a Nicaraguan Cedula number 
+    (nicaraguan oficial identification document).
+
+.. class:: ni.forms.NIPhoneNumberField
+
+    A form field that validates input as a Nicaraguan Telephone number. Seven digits 
+    with or without a hypen.
+
+
 Norway (``no``)
 ===============
 
