我得到當我點擊提交我的虛擬形式Django的形式禁止(403)錯誤
禁止(403)
CSRF驗證失敗的按鈕下面的錯誤。請求中止
我views.py(做了以上所需的進口)是這樣的:
def search(request):
errors=[]
if request.method=="POST":
if not request.POST['name']:
errors.append('Name field is empty')
if not request.POST['subject']:
errors.append('Subject field is empty')
if not request.POST['age']:
errors.append('Age field is empty')
if not errors:
thank()
return render_to_response('search.html',{'errors':errors},context_instance=RequestContext(request))
def thank(search):
return HttpResponse('<html><p>Post done successfully</p></html>')
我search.html是:
<form method="post" action='/search/'>
<p>Name: <input type="text" name="name"/></p>
<p>Subject <input type="text" name="subject"/></p>
<p>Age: <input type="text" name="age"/></p>
<input type="submit" value="Hit Me!!"/>
</form>
</body>
</html>
有人請讓我知道,我如何克服這個錯誤?