parent
d5ed81c795
commit
8248d14029
|
@ -90,9 +90,6 @@ Model field Form field
|
|||
|
||||
``NullBooleanField`` ``CharField``
|
||||
|
||||
``PhoneNumberField`` ``USPhoneNumberField``
|
||||
(from ``django.contrib.localflavor.us``)
|
||||
|
||||
``PositiveIntegerField`` ``IntegerField``
|
||||
|
||||
``PositiveSmallIntegerField`` ``IntegerField``
|
||||
|
|
|
@ -91,15 +91,6 @@ class WriterProfile(models.Model):
|
|||
def __str__(self):
|
||||
return "%s is %s" % (self.writer, self.age)
|
||||
|
||||
from django.contrib.localflavor.us.models import PhoneNumberField
|
||||
@python_2_unicode_compatible
|
||||
class PhoneNumber(models.Model):
|
||||
phone = PhoneNumberField()
|
||||
description = models.CharField(max_length=20)
|
||||
|
||||
def __str__(self):
|
||||
return self.phone
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class TextFile(models.Model):
|
||||
description = models.CharField(max_length=20)
|
||||
|
|
|
@ -18,7 +18,7 @@ from django.utils import six
|
|||
from .models import (Article, ArticleStatus, BetterWriter, BigInt, Book,
|
||||
Category, CommaSeparatedInteger, CustomFieldForExclusionModel, DerivedBook,
|
||||
DerivedPost, ExplicitPK, FlexibleDatePost, ImprovedArticle,
|
||||
ImprovedArticleWithParentLink, Inventory, PhoneNumber, Post, Price,
|
||||
ImprovedArticleWithParentLink, Inventory, Post, Price,
|
||||
Product, TextFile, Writer, WriterProfile, test_images)
|
||||
|
||||
if test_images:
|
||||
|
@ -148,10 +148,6 @@ class WriterProfileForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = WriterProfile
|
||||
|
||||
class PhoneNumberForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = PhoneNumber
|
||||
|
||||
class TextFileForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TextFile
|
||||
|
@ -167,7 +163,7 @@ class ModelFormWithMedia(forms.ModelForm):
|
|||
'all': ('/some/form/css',)
|
||||
}
|
||||
class Meta:
|
||||
model = PhoneNumber
|
||||
model = TextFile
|
||||
|
||||
class CommaSeparatedIntegerForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
@ -1149,12 +1145,6 @@ class OldFormForXTests(TestCase):
|
|||
</select></p>
|
||||
<p><label for="id_age">Age:</label> <input type="text" name="age" value="65" id="id_age" /></p>''' % (w_woodward.pk, w_bernstein.pk, bw.pk, w_royko.pk))
|
||||
|
||||
def test_phone_number_field(self):
|
||||
f = PhoneNumberForm({'phone': '(312) 555-1212', 'description': 'Assistance'})
|
||||
self.assertEqual(f.is_valid(), True)
|
||||
self.assertEqual(f.cleaned_data['phone'], '312-555-1212')
|
||||
self.assertEqual(f.cleaned_data['description'], 'Assistance')
|
||||
|
||||
def test_file_field(self):
|
||||
# Test conditions when files is either not given or empty.
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ This class sets up a model for each model field type
|
|||
from django.db import models
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.localflavor.us.models import USStateField, PhoneNumberField
|
||||
|
||||
# The following classes are for testing basic data
|
||||
# marshalling, including NULL values, where allowed.
|
||||
|
@ -58,9 +57,6 @@ class GenericIPAddressData(models.Model):
|
|||
class NullBooleanData(models.Model):
|
||||
data = models.NullBooleanField(null=True)
|
||||
|
||||
class PhoneData(models.Model):
|
||||
data = PhoneNumberField(null=True)
|
||||
|
||||
class PositiveIntegerData(models.Model):
|
||||
data = models.PositiveIntegerField(null=True)
|
||||
|
||||
|
@ -79,9 +75,6 @@ class TextData(models.Model):
|
|||
class TimeData(models.Model):
|
||||
data = models.TimeField(null=True)
|
||||
|
||||
class USStateData(models.Model):
|
||||
data = USStateField(null=True)
|
||||
|
||||
class Tag(models.Model):
|
||||
"""A tag on an item."""
|
||||
data = models.SlugField()
|
||||
|
@ -212,9 +205,6 @@ class GenericIPAddressPKData(models.Model):
|
|||
# class NullBooleanPKData(models.Model):
|
||||
# data = models.NullBooleanField(primary_key=True)
|
||||
|
||||
class PhonePKData(models.Model):
|
||||
data = PhoneNumberField(primary_key=True)
|
||||
|
||||
class PositiveIntegerPKData(models.Model):
|
||||
data = models.PositiveIntegerField(primary_key=True)
|
||||
|
||||
|
@ -233,9 +223,6 @@ class SmallPKData(models.Model):
|
|||
# class TimePKData(models.Model):
|
||||
# data = models.TimeField(primary_key=True)
|
||||
|
||||
class USStatePKData(models.Model):
|
||||
data = USStateField(primary_key=True)
|
||||
|
||||
class ComplexModel(models.Model):
|
||||
field1 = models.CharField(max_length=10)
|
||||
field2 = models.CharField(max_length=10)
|
||||
|
|
|
@ -28,14 +28,14 @@ from django.utils.unittest import skipUnless
|
|||
|
||||
from .models import (BooleanData, CharData, DateData, DateTimeData, EmailData,
|
||||
FileData, FilePathData, DecimalData, FloatData, IntegerData, IPAddressData,
|
||||
GenericIPAddressData, NullBooleanData, PhoneData, PositiveIntegerData,
|
||||
GenericIPAddressData, NullBooleanData, PositiveIntegerData,
|
||||
PositiveSmallIntegerData, SlugData, SmallData, TextData, TimeData,
|
||||
USStateData, GenericData, Anchor, UniqueAnchor, FKData, M2MData, O2OData,
|
||||
GenericData, Anchor, UniqueAnchor, FKData, M2MData, O2OData,
|
||||
FKSelfData, M2MSelfData, FKDataToField, FKDataToO2O, M2MIntermediateData,
|
||||
Intermediate, BooleanPKData, CharPKData, EmailPKData, FilePathPKData,
|
||||
DecimalPKData, FloatPKData, IntegerPKData, IPAddressPKData,
|
||||
GenericIPAddressPKData, PhonePKData, PositiveIntegerPKData,
|
||||
PositiveSmallIntegerPKData, SlugPKData, SmallPKData, USStatePKData,
|
||||
GenericIPAddressPKData, PositiveIntegerPKData,
|
||||
PositiveSmallIntegerPKData, SlugPKData, SmallPKData,
|
||||
AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel, BaseModel,
|
||||
ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel,
|
||||
ProxyProxyBaseModel, BigIntegerData, LengthModel, Tag, ComplexModel,
|
||||
|
@ -218,8 +218,6 @@ test_data = [
|
|||
(data_obj, 100, NullBooleanData, True),
|
||||
(data_obj, 101, NullBooleanData, False),
|
||||
(data_obj, 102, NullBooleanData, None),
|
||||
(data_obj, 110, PhoneData, "212-634-5789"),
|
||||
(data_obj, 111, PhoneData, None),
|
||||
(data_obj, 120, PositiveIntegerData, 123456789),
|
||||
(data_obj, 121, PositiveIntegerData, None),
|
||||
(data_obj, 130, PositiveSmallIntegerData, 12),
|
||||
|
@ -239,9 +237,6 @@ The end."""),
|
|||
(data_obj, 162, TextData, None),
|
||||
(data_obj, 170, TimeData, datetime.time(10,42,37)),
|
||||
(data_obj, 171, TimeData, None),
|
||||
(data_obj, 180, USStateData, "MA"),
|
||||
(data_obj, 181, USStateData, None),
|
||||
(data_obj, 182, USStateData, ""),
|
||||
|
||||
(generic_obj, 200, GenericData, ['Generic Object 1', 'tag1', 'tag2']),
|
||||
(generic_obj, 201, GenericData, ['Generic Object 2', 'tag2', 'tag3']),
|
||||
|
@ -320,7 +315,6 @@ The end."""),
|
|||
(pk_obj, 695, GenericIPAddressPKData, "fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"),
|
||||
# (pk_obj, 700, NullBooleanPKData, True),
|
||||
# (pk_obj, 701, NullBooleanPKData, False),
|
||||
(pk_obj, 710, PhonePKData, "212-634-5789"),
|
||||
(pk_obj, 720, PositiveIntegerPKData, 123456789),
|
||||
(pk_obj, 730, PositiveSmallIntegerPKData, 12),
|
||||
(pk_obj, 740, SlugPKData, "this-is-a-slug"),
|
||||
|
@ -332,7 +326,6 @@ The end."""),
|
|||
# Several of them.
|
||||
# The end."""),
|
||||
# (pk_obj, 770, TimePKData, datetime.time(10,42,37)),
|
||||
(pk_obj, 780, USStatePKData, "MA"),
|
||||
# (pk_obj, 790, XMLPKData, "<foo></foo>"),
|
||||
|
||||
(data_obj, 800, AutoNowDateTimeData, datetime.datetime(2006,6,16,10,42,37)),
|
||||
|
|
Loading…
Reference in New Issue