【发布时间】:2019-03-14 07:54:23
【问题描述】:
我想在 Django 的表格中使用 select 选项,但它不起作用。
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")))
我的html
<td>
<form method = "post" action = "">
{% csrf_token %}
{{ form.as_p }}
</form></td>
而且,我怎样才能在每一行中获得一个选定的值?
【问题讨论】:
-
您好,欢迎来到 SO。您能否更清楚地了解您正在使用的数据源。目前还不清楚你到底想做什么。
-
缩进在 Python 中很重要。请修正您的缩进,使其有意义。
-
除非必要,否则不要使用
global!并且类名的第一个字符大写。见:python.org/dev/peps/pep-0008
标签: python django select option