在django中提交后,我试图保留选择选项的值,但无法执行。当我提交按钮时,选择框消失了。
有什么建议吗?
forms.py
class WardForm(forms.Form):
ward_no = forms.ChoiceField(choices=[(x, x) for x in ['All', '1', '2', '3','4','5','6','7','8','9','10','11','12','13','14','15']])
Views.py
def post(request, template_name='report.html'):
if request.method == 'POST':
form=WardForm(request.POST)
return render(request, template_name, {'form': form})
reports.html
{{ form.as_p}}