我有我的模板獲得的值:Django的,從POST
This is passed by {{form}}
<form action="" method="POST">
Inicio: <input type="text" id="start">
<input type="submit" value="Sned" >
{% csrf_token %}
</form>
在views.py
然後
def test(request):
if request.method != 'POST':
context = {'form': 'by GET'}
return render(request, 'test.html', context)
else:
if 'start' in request.POST:
start = request.POST['start']
else:
start = False
context = {'form': start}
return render(request, 'test.html', context)
似乎總是返回False
如果我不檢查密鑰的存在我有這個錯誤:
MultiValueDictKeyError
而且erropage說: 「 '開始'」(單加雙引號)
非常感謝你:) – Alexev
你可以把它標記爲正確答案 – hspandher
也做到了,但不知它仍沒有被標記爲綠色,當我嘗試做一遍它說生病不得不等待10分鐘後10 – Alexev