1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Fixed #3268 -- Changed default model formfields to use a select widget when the

field has a choices attribute. Based on a patch from mrmachine.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5119 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2007-04-28 14:18:03 +00:00
parent b09bdd2ae8
commit d9cc22b3e3
2 changed files with 41 additions and 2 deletions

View File

@@ -344,6 +344,8 @@ class Field(object):
def formfield(self, form_class=forms.CharField, **kwargs):
"Returns a django.newforms.Field instance for this database Field."
defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
if self.choices:
defaults['widget'] = forms.Select(choices=self.get_choices())
defaults.update(kwargs)
return form_class(**defaults)