0

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>
2
  • If this answer helped you mark it as accepted. It's a good practice in StackOverflow to do so. Commented Mar 19, 2017 at 10:58
  • I am sorry for the delay in accepting your answer.Thanks... Commented Mar 22, 2017 at 4:12

1 Answer 1

5

Typo there:

Change this {{% csrf_token %}} to this {% csrf_token %}

However, these kind of errors can easily be discovered by your side since Django's traceback is very detailed and points to the line of what caused the error.

Best regards!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.