Ticket #8664: 8664-2.diff
File 8664-2.diff, 5.9 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/__init__.py
731 731 defaults.update(kwargs) 732 732 return super(NullBooleanField, self).formfield(**defaults) 733 733 734 class PhoneNumberField(Field):735 def get_internal_type(self):736 return "PhoneNumberField"737 738 def formfield(self, **kwargs):739 from django.contrib.localflavor.us.forms import USPhoneNumberField740 defaults = {'form_class': USPhoneNumberField}741 defaults.update(kwargs)742 return super(PhoneNumberField, self).formfield(**defaults)743 744 734 class PositiveIntegerField(IntegerField): 745 735 def get_internal_type(self): 746 736 return "PositiveIntegerField" -
django/db/backends/postgresql/creation.py
21 21 'IPAddressField': 'inet', 22 22 'NullBooleanField': 'boolean', 23 23 'OneToOneField': 'integer', 24 'PhoneNumberField': 'varchar(20)',25 24 'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)', 26 25 'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)', 27 26 'SlugField': 'varchar(%(max_length)s)', -
django/db/backends/sqlite3/creation.py
22 22 'IPAddressField': 'char(15)', 23 23 'NullBooleanField': 'bool', 24 24 'OneToOneField': 'integer', 25 'PhoneNumberField': 'varchar(20)',26 25 'PositiveIntegerField': 'integer unsigned', 27 26 'PositiveSmallIntegerField': 'smallint unsigned', 28 27 'SlugField': 'varchar(%(max_length)s)', -
django/db/backends/mysql/creation.py
21 21 'IPAddressField': 'char(15)', 22 22 'NullBooleanField': 'bool', 23 23 'OneToOneField': 'integer', 24 'PhoneNumberField': 'varchar(20)',25 24 'PositiveIntegerField': 'integer UNSIGNED', 26 25 'PositiveSmallIntegerField': 'smallint UNSIGNED', 27 26 'SlugField': 'varchar(%(max_length)s)', -
django/db/backends/oracle/creation.py
30 30 'IPAddressField': 'VARCHAR2(15)', 31 31 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', 32 32 'OneToOneField': 'NUMBER(11)', 33 'PhoneNumberField': 'VARCHAR2(20)',34 33 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', 35 34 'PositiveSmallIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', 36 35 'SlugField': 'NVARCHAR2(50)', -
django/contrib/localflavor/us/models.py
1 from django.db.models.fields import Field 2 3 class PhoneNumberField(Field): 4 def db_type(self): 5 from django.conf import settings 6 if settings.DATABASE_ENGINE == 'oracle': 7 return 'VARCHAR2(20)' 8 else: 9 return 'varchar(20)' 10 11 def get_internal_type(self): 12 return "PhoneNumberField" 13 14 def formfield(self, **kwargs): 15 from django.contrib.localflavor.us.forms import USPhoneNumberField 16 defaults = {'form_class': USPhoneNumberField} 17 defaults.update(kwargs) 18 return super(PhoneNumberField, self).formfield(**defaults) -
tests/modeltests/model_forms/models.py
82 82 def __unicode__(self): 83 83 return "%s is %s" % (self.writer, self.age) 84 84 85 from django.contrib.localflavor.us.models import PhoneNumberField 85 86 class PhoneNumber(models.Model): 86 phone = models.PhoneNumberField()87 phone = PhoneNumberField() 87 88 description = models.CharField(max_length=20) 88 89 89 90 def __unicode__(self): -
tests/regressiontests/serializers_regress/models.py
8 8 from django.db import models 9 9 from django.contrib.contenttypes import generic 10 10 from django.contrib.contenttypes.models import ContentType 11 from django.contrib.localflavor.us.models import PhoneNumberField 11 12 12 13 # The following classes are for testing basic data 13 14 # marshalling, including NULL values. … … 52 53 data = models.NullBooleanField(null=True) 53 54 54 55 class PhoneData(models.Model): 55 data = models.PhoneNumberField(null=True)56 data = PhoneNumberField(null=True) 56 57 57 58 class PositiveIntegerData(models.Model): 58 59 data = models.PositiveIntegerField(null=True) … … 188 189 # data = models.NullBooleanField(primary_key=True) 189 190 190 191 class PhonePKData(models.Model): 191 data = models.PhoneNumberField(primary_key=True)192 data = PhoneNumberField(primary_key=True) 192 193 193 194 class PositiveIntegerPKData(models.Model): 194 195 data = models.PositiveIntegerField(primary_key=True)