Ticket #10969: localflavor.us.models.usstatefield.2.diff
File localflavor.us.models.usstatefield.2.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/contrib/localflavor/us/models.py
1 1 from django.conf import settings 2 from django.db.models.fields import Field 2 from django.db.models.fields import Field, CharField 3 3 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) 4 class USStateField(models.CharField): 5 def __init__(self, *args, **kwargs): 6 kwargs['choices'] = STATE_CHOICES 7 kwargs['max_length'] = 2 8 super(USStateField, self).__init__(*args, **kwargs) 19 9 20 10 class PhoneNumberField(Field): 21 11 def get_internal_type(self): -
django/contrib/localflavor/us/models.py
1 1 from django.conf import settings 2 from django.db.models.fields import Field 2 from django.db.models.fields import Field, CharField 3 from django.contrib.localflavor.us.us_states import STATE_CHOICES 3 4 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) 19 10 20 11 class PhoneNumberField(Field): 21 12 def get_internal_type(self):