mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
6a75c8a52e
commit
016d75cc7f
|
@ -612,6 +612,9 @@ class OneToOneField(RelatedField, IntegerField):
|
||||||
if not cls._meta.one_to_one_field:
|
if not cls._meta.one_to_one_field:
|
||||||
cls._meta.one_to_one_field = self
|
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):
|
class ManyToManyField(RelatedField, Field):
|
||||||
def __init__(self, to, **kwargs):
|
def __init__(self, to, **kwargs):
|
||||||
kwargs['verbose_name'] = kwargs.get('verbose_name', None)
|
kwargs['verbose_name'] = kwargs.get('verbose_name', None)
|
||||||
|
|
Loading…
Reference in New Issue