Search code examples
csrfdjango-registration

csrf error when using django-registration


Am using django-registration for user account activation.

in my registration_form.html I have

{% extends "base.html" %}
{% block title %} Register {% endblock %}
{% load i18n %}
{% block menu %}

<li class="home-page"><a href="/utriga"><span></span></a></li>
<li><a href="/utriga/about">About Us</a></li>
<li><a href="/utriga/downloads">Downloads</a></li>
<li><a href="/utriga/blog">Blog</a></li>
<li class="current " ><a href="/utriga/post">Advertise</a></li>
<li><a href="/utriga/contact">Contact Us</a></li>

{% endblock %}

{% block content %}
<form method="post" action=".">

    {{ form.as_p }}

    <input type="submit" value="{% trans 'Submit' %}" />
</form>
{% endblock %}

The problem is that it worked for a while and then stopped, Giving the error page.

Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
     CSRF token missing or incorrect.

I dont understand why it worked before and stopped even though I changed nothing. Is load i18n, the problem ? Help please


Solution

  • You are missing the csrf token in the form.

    Place {% csrf_token %} inside the form and see if it works.