Forbidden (403) CSRF verification failed. Request aborted

You need to add {% csrf_token %} in your form

https://docs.djangoproject.com/en/2.2/ref/csrf/

like that :

<form>
    {% csrf_token %}
    <anything_else>
</form>

Also, you have to use RequestContext(request) everytime you use render_to_response :

return render_to_response("login.html",
    {"registration_id":registration_id},
    context_instance=RequestContext(request))

And you have to import authenticate and login :

from django.contrib.auth import authenticate, login

Leave a Comment