Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12474 - Removing SQL specific bits from USPhoneNumberField. Pa…

…tch from Alex Gaynor.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12049 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0e883508936fc5d8e499e702a62413440fa66f0b 1 parent d48f530
Jannis Leidel authored January 01, 2010
4  django/contrib/localflavor/us/forms.py
@@ -3,7 +3,7 @@
3 3
 """
4 4
 
5 5
 from django.forms import ValidationError
6  
-from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
  6
+from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES, CharField
7 7
 from django.utils.encoding import smart_unicode
8 8
 from django.utils.translation import ugettext_lazy as _
9 9
 import re
@@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):
20 20
         super(USZipCodeField, self).__init__(r'^\d{5}(?:-\d{4})?$',
21 21
             max_length=None, min_length=None, *args, **kwargs)
22 22
 
23  
-class USPhoneNumberField(Field):
  23
+class USPhoneNumberField(CharField):
24 24
     default_error_messages = {
25 25
         'invalid': u'Phone numbers must be in XXX-XXX-XXXX format.',
26 26
     }
16  django/contrib/localflavor/us/models.py
... ...
@@ -1,6 +1,6 @@
1 1
 from django.conf import settings
2 2
 from django.utils.translation import ugettext_lazy as _
3  
-from django.db.models.fields import Field, CharField
  3
+from django.db.models.fields import CharField
4 4
 from django.contrib.localflavor.us.us_states import STATE_CHOICES
5 5
 
6 6
 class USStateField(CharField):
@@ -12,22 +12,16 @@ def __init__(self, *args, **kwargs):
12 12
         kwargs['max_length'] = 2
13 13
         super(USStateField, self).__init__(*args, **kwargs)
14 14
 
15  
-class PhoneNumberField(Field):
  15
+class PhoneNumberField(CharField):
16 16
 
17 17
     description = _("Phone number")
18 18
 
19  
-    def get_internal_type(self):
20  
-        return "PhoneNumberField"
21  
-
22  
-    def db_type(self, connection):
23  
-        if connection.settings_dict['ENGINE'] == 'django.db.backends.oracle':
24  
-            return 'VARCHAR2(20)'
25  
-        else:
26  
-            return 'varchar(20)'
  19
+    def __init__(self, *args, **kwargs):
  20
+        kwargs['max_length'] = 20
  21
+        super(PhoneNumberField, self).__init__(*args, **kwargs)
27 22
 
28 23
     def formfield(self, **kwargs):
29 24
         from django.contrib.localflavor.us.forms import USPhoneNumberField
30 25
         defaults = {'form_class': USPhoneNumberField}
31 26
         defaults.update(kwargs)
32 27
         return super(PhoneNumberField, self).formfield(**defaults)
33  
-

0 notes on commit 0e88350

Please sign in to comment.
Something went wrong with that request. Please try again.