我试图在我的模板中显示一个下拉菜单,但我得到以下错误
File "forms.py" in DropdownSelectionForm
101. selection = forms.ChoiceField(choices=MY_CHOICES, widget = Select)
Exception Type: NameError at /
Exception Value: name 'Select' is not defined
这是我要展示表单的模板
^{pr2}$给你表单.py在
MY_CHOICES = (
('Dermatologist', 'Dermatologist'),
('Dentist', 'Dentist'),
('Opthalmologist', 'Opthalmologist'),
)
class DropdownSelectionForm(forms.Form):
selection = forms.ChoiceField(choices=MY_CHOICES, widget = Select)
Python找不到
Select
,我看到你已经导入了django.forms
,所以试试widget=forms.Select
像Python中的其他任何东西一样,您需要正确地引用对象。在本例中,Select是通过forms模块提供的,与ChoiceField完全相同。在
相关问题 更多 >
编程相关推荐