equal
deleted
inserted
replaced
|
1 from django.conf import settings |
|
2 from django.db.models.fields import Field |
|
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) |
|
19 |
|
20 class PhoneNumberField(Field): |
|
21 def get_internal_type(self): |
|
22 return "PhoneNumberField" |
|
23 |
|
24 def db_type(self): |
|
25 if settings.DATABASE_ENGINE == 'oracle': |
|
26 return 'VARCHAR2(20)' |
|
27 else: |
|
28 return 'varchar(20)' |
|
29 |
|
30 def formfield(self, **kwargs): |
|
31 from django.contrib.localflavor.us.forms import USPhoneNumberField |
|
32 defaults = {'form_class': USPhoneNumberField} |
|
33 defaults.update(kwargs) |
|
34 return super(PhoneNumberField, self).formfield(**defaults) |
|
35 |