我想在Django表中使用选择选项,但这不起作用。
myview.py
def Data_Handling(request) :
if request.method == 'POST' :
form = getValue(request.POST)
else :
form = getValue()
global excel_data_name
agrs = {"excel_data_name" : excel_data_name, "form" : form }
return render(request, 'ex01/data_handling.html', agrs )
myforms.py
class getValue(forms.Form) :
value = forms.ChoiceField(widget=forms.Select(choices=("A", "B", "C")))
myhtml
<td>
<form method = "post" action = "">
{% csrf_token %}
{{ form.as_p }}
</form></td>
然后,如何在每一行中获取选定的值?
答案 0 :(得分:0)
尝试一下
class getValue(forms.Form) :
value = forms.ChoiceField(choices=(('A', 'A'),
('B', 'B'),
('C', 'C')))