I am trying to build a feedback form but i am getting this error: Could not parse the remainder: '% csrf_token %' from '% csrf_token %'
Here is my views.py:
def contact(request):
if request.method=='POST':
form=ContactForm(request.POST)
if form.is_valid():
topic=form.cleaned_data['topic']
message=form.cleaned_data['message']
sender=form.cleaned_data.get('sender')
send_mail(
'Feedback from your site,topic:%s'%topic,
message,
sender,
['[email protected]']
)
return HttpResponseRedirect('/contact/thanks/')
else:
form=ContactForm()
context={'form':form}
return render(request,'blog/contact.html',context)
Here is my template contact.html:
<!DOCTYPE html>
<html>
<head>
<title>Feedback Form</title>
</head>
<body>
<h1>Contact Us</h1>
<form action="." method="post" >
{{% csrf_token %}}
<table>{{form.as_table}}</table>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>