You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Views » [SOLVED] CSRF_FAILURE_VIEW Not Working

I'm still pretty new to Django and have been following some online tutorials to learn it.

I've run into a problem where the CSRF_FAILURE_VIEW doesn't seem to get used correctly and I'm not sure why.

Here is the relevant code:

myProject/custom/csrf/views.py
from django.shortcuts import render_to_response

def csrf_failure(request, reason=""):
    ctx = {'reason':reason}
    return render_to_response("csrf/failure.html", ctx)


myProject/settings.py
TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)


CSRF_FAILURE_VIEW = 'myProject.custom.csrf.views.csrf_failure'


myProject/templates/csrf/failure.html
{% extends 'homepage/index.html' %}

{% block content %}
    <h1>Invalid Request</h1>
{% endblock %}


From what I can tell my version of csrf_failure never gets called.

From what I've read here I've done this correctly.

There are no errors, but my custom view never gets used.

Any suggestions?



SOLVED:

While following the tutorial I was told to place a @csrf_exempt in front of my contact view. The later tutorial did not have me remove that. When I remove that token everything works great.

Hope this helps somebody!

--- Last Edited by Rico at 2012-03-17 10:55:32 ---
i too have some issues with csrf missing .I simply do the following things
place {csrf_token} after POST in html
and import RequestContext in views
this works for me .If some one has any issue like this ,feel free to contact me
I can and I will





Powered by Sphene Community Tools