1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Changed database PhoneNumberField to use USPhoneNumberField as its newforms form field (instead of IntegerField)

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4556 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2007-02-21 05:59:46 +00:00
parent ec2eb4d18f
commit abc949f584
2 changed files with 22 additions and 0 deletions

View File

@@ -54,6 +54,13 @@ class Article(models.Model):
def __str__(self):
return self.headline
class PhoneNumber(models.Model):
phone = models.PhoneNumberField()
description = models.CharField(maxlength=20)
def __str__(self):
return self.phone
__test__ = {'API_TESTS': """
>>> from django.newforms import form_for_model, form_for_instance, save_instance, BaseForm, Form, CharField
>>> import datetime
@@ -445,4 +452,13 @@ ValidationError: [u'Select a valid choice. 10 is not one of the available choice
Traceback (most recent call last):
...
ValidationError: [u'Select a valid choice. 10 is not one of the available choices.']
# PhoneNumberField ############################################################
>>> PhoneNumberForm = form_for_model(PhoneNumber)
>>> f = PhoneNumberForm({'phone': '(312) 555-1212', 'description': 'Assistance'})
>>> f.is_valid()
True
>>> f.clean_data
{'phone': u'312-555-1212', 'description': u'Assistance'}
"""}