mirror of
https://github.com/django/django.git
synced 2025-11-20 19:47:55 +00:00
newforms: Fixed confusing behavior when setting choices for ChoiceFields and their corresponding Widgets. Now, a Widget uses the choices from its ChoiceField regardless of whether the Widget has its own choices.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4378 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c770803f72
commit
f073318668
2 changed files with 38 additions and 1 deletions
|
|
@ -319,7 +319,8 @@ class BooleanField(Field):
|
|||
class ChoiceField(Field):
|
||||
def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None):
|
||||
if isinstance(widget, type):
|
||||
widget = widget(choices=choices)
|
||||
widget = widget()
|
||||
widget.choices = choices
|
||||
super(ChoiceField, self).__init__(required, widget, label, initial)
|
||||
self.choices = choices
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue