I am getting the below error when i click on submit button of my dummy form
Forbidden (403)
CSRF verification failed. Request aborted
My views.py(have done the required imports above) looks like this:
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>')
My search.html is :
<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>
Someone please let me know,how can i overcome this error?