1 from django.contrib.localflavor.us.forms import USZipCodeField as USZipCodeFormField
2 from django.core.validators import RegexValidator
3 from django.db import models
6 class USZipCodeField(models.CharField):
7 default_validators = [RegexValidator(r'^\d{5}(?:-\d{4})?$')]
9 def __init__(self, *args, **kwargs):
10 kwargs['max_length'] = 10
11 super(USZipCodeField, self).__init__(*args, **kwargs)
13 def formfield(self, form_class=USZipCodeFormField, **kwargs):
14 return super(USZipCodeField, self).formfield(form_class, **kwargs)
18 from south.modelsinspector import add_introspection_rules
22 add_introspection_rules([], ["^philo\.contrib\.julian\.fields\.USZipCodeField"])