4 | | class USStateField(Field): |
5 | | def get_internal_type(self): |
6 | | return "USStateField" |
7 | | |
8 | | def db_type(self): |
9 | | if settings.DATABASE_ENGINE == 'oracle': |
10 | | return 'CHAR(2)' |
11 | | else: |
12 | | return 'varchar(2)' |
13 | | |
14 | | def formfield(self, **kwargs): |
15 | | from django.contrib.localflavor.us.forms import USStateSelect |
16 | | defaults = {'widget': USStateSelect} |
17 | | defaults.update(kwargs) |
18 | | return super(USStateField, self).formfield(**defaults) |
| 5 | class USStateField(models.CharField): |
| 6 | def __init__(self, *args, **kwargs): |
| 7 | kwargs['choices'] = STATE_CHOICES |
| 8 | kwargs['max_length'] = 2 |
| 9 | super(USStateField, self).__init__(*args, **kwargs) |