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

Fixed #7947 -- Handle the display of OneToOneField in model forms correctly. Thanks tyson for the report and original patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8469 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner
2008-08-22 19:27:26 +00:00
parent 640e930dc1
commit 1b8b9686fa
3 changed files with 29 additions and 2 deletions

View File

@@ -54,6 +54,12 @@ class Article(models.Model):
def __unicode__(self):
return self.headline
class ImprovedArticle(models.Model):
article = models.OneToOneField(Article)
class ImprovedArticleWithParentLink(models.Model):
article = models.OneToOneField(Article, parent_link=True)
class PhoneNumber(models.Model):
phone = models.PhoneNumberField()
description = models.CharField(max_length=20)
@@ -773,6 +779,20 @@ ValidationError: [u'Select a valid choice. 4 is not one of the available choices
>>> list(f.choices)
[(1L, 'multicategory Entertainment'), (2L, "multicategory It's a test"), (3L, 'multicategory Third'), (4L, 'multicategory Fourth')]
# OneToOneField ###############################################################
>>> class ImprovedArticleForm(ModelForm):
... class Meta:
... model = ImprovedArticle
>>> ImprovedArticleForm.base_fields.keys()
['article']
>>> class ImprovedArticleWithParentLinkForm(ModelForm):
... class Meta:
... model = ImprovedArticleWithParentLink
>>> ImprovedArticleWithParentLinkForm.base_fields.keys()
[]
# PhoneNumberField ############################################################
>>> class PhoneNumberForm(ModelForm):