我試着去獲得價值形成Django的一個職位,但它傳遞一個空場`高清PersonEmail(請求):POST不工作
我試着去獲得價值形成Django的一個職位,但它傳遞一個空現場`高清PersonEmail(請求):
if request.method == "POST":
form1 = PersonForm(request.POST, prefix="form1")
form2 = EmailForm(request.POST, prefix="form2")
name = form2['email'].value
return HttpResponse(name)
else:
form1 = PersonForm()
form2 = EmailForm()
return render(request, 'CreatePersonEmail.html', locals())`
,但是當我把它們分開,即
Im trying to get the value form a post in django but it pass an empty field `def PersonEmail(request):
if request.method == "POST":
# form1 = PersonForm(request.POST, prefix="form1")
form2 = EmailForm(request.POST, prefix="form2")
name = form2['email'].value
return HttpResponse(name)
else:
form1 = PersonForm()
form2 = EmailForm()
return render(request, 'CreatePersonEmail.html', locals())`
它給我的字段的值。
爲什麼?我怎樣才能讓它獲得這兩個表單字段的值?
好的,我看到了問題,我明白了,我修改了代碼並做了一些類似上面顯示的內容,但是當它驗證表單時,請勿通過,並且所有字段都是正確的:/ –