Ticket #8664: 8664-1.2.diff

File 8664-1.2.diff, 3.3 KB (added by gkelly, 16 years ago)

Same as above, but without the newline warning

  • django/db/models/fields/__init__.py

     
    725725        defaults.update(kwargs)
    726726        return super(NullBooleanField, self).formfield(**defaults)
    727727
    728 class PhoneNumberField(Field):
    729     def get_internal_type(self):
    730         return "PhoneNumberField"
    731 
    732     def formfield(self, **kwargs):
    733         from django.contrib.localflavor.us.forms import USPhoneNumberField
    734         defaults = {'form_class': USPhoneNumberField}
    735         defaults.update(kwargs)
    736         return super(PhoneNumberField, self).formfield(**defaults)
    737 
    738728class PositiveIntegerField(IntegerField):
    739729    def get_internal_type(self):
    740730        return "PositiveIntegerField"
  • django/contrib/localflavor/us/models.py

     
     1from django.db.models.fields import Field
     2
     3class PhoneNumberField(Field):
     4    def get_internal_type(self):
     5        return "PhoneNumberField"
     6
     7    def formfield(self, **kwargs):
     8        from django.contrib.localflavor.us.forms import USPhoneNumberField
     9        defaults = {'form_class': USPhoneNumberField}
     10        defaults.update(kwargs)
     11        return super(PhoneNumberField, self).formfield(**defaults)
  • tests/modeltests/model_forms/models.py

     
    7070    pass
    7171
    7272class PhoneNumber(models.Model):
    73     phone = models.PhoneNumberField()
     73    from django.contrib.localflavor.us.models import PhoneNumberField
     74    phone = PhoneNumberField()
    7475    description = models.CharField(max_length=20)
    7576
    7677    def __unicode__(self):
  • tests/regressiontests/serializers_regress/models.py

     
    88from django.db import models
    99from django.contrib.contenttypes import generic
    1010from django.contrib.contenttypes.models import ContentType
     11from django.contrib.localflavor.us.models import PhoneNumberField
    1112
    1213# The following classes are for testing basic data
    1314# marshalling, including NULL values.
     
    5253    data = models.NullBooleanField(null=True)
    5354
    5455class PhoneData(models.Model):
    55     data = models.PhoneNumberField(null=True)
     56    data = PhoneNumberField(null=True)
    5657
    5758class PositiveIntegerData(models.Model):
    5859    data = models.PositiveIntegerField(null=True)
     
    188189#     data = models.NullBooleanField(primary_key=True)
    189190
    190191class PhonePKData(models.Model):
    191     data = models.PhoneNumberField(primary_key=True)
     192    data = PhoneNumberField(primary_key=True)
    192193
    193194class PositiveIntegerPKData(models.Model):
    194195    data = models.PositiveIntegerField(primary_key=True)
     
    251252class ExplicitInheritBaseModel(BaseModel):
    252253    parent = models.OneToOneField(BaseModel)
    253254    child_data = models.IntegerField()
Back to Top