【发布时间】:2020-10-01 11:34:37
【问题描述】:
这是我的表格:
class ch_form(forms.Form):
ch_field = forms.ChoiceField(
required=True , label= 'ch_field : ' ,
)
这是我的观点:
def testView(request):
form = ch_form(
initial={
'ch_field':[
(1, 'test1'),
(2, 'test2'),
(3, 'test3'),
]
}
)
但它不起作用。
所以我的问题是如何在运行时在视图函数中设置forms.ChoiceField 的值。
对不起,我的英语不好。
【问题讨论】:
标签: python django django-forms django-views