From 016d75cc7fab107e8116211b5091d781a3bf0d24 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 27 Dec 2006 05:27:47 +0000 Subject: [PATCH] newforms: Implemented formfield() for database OneToOneField class. Not sure about this one, but one-to-one fields are eventually going to be refactored so it's not a big deal if it doesn't work git-svn-id: http://code.djangoproject.com/svn/django/trunk@4248 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/related.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index eb388fcb6d..194ffd9610 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -612,6 +612,9 @@ class OneToOneField(RelatedField, IntegerField): if not cls._meta.one_to_one_field: cls._meta.one_to_one_field = self + def formfield(self): + return forms.ChoiceField(choices=self.get_choices_default(), required=not self.blank, label=capfirst(self.verbose_name)) + class ManyToManyField(RelatedField, Field): def __init__(self, to, **kwargs): kwargs['verbose_name'] = kwargs.get('verbose_name', None)