Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (32 sloc) 1.292 kb
# coding:utf-8
csrf related views
Display the normal debug page and not the minimal csrf debug page.
usage: Add this to your settings:
:copyleft: 2012 by the django-tools team, see AUTHORS for more details.
:license: GNU GPL v3 or above, see LICENSE for more details.
from __future__ import absolute_import, division, print_function
from django.views.csrf import csrf_failure
from django.conf import settings
from django.http import Http404
class CsrfFailure(Exception):
def debug_csrf_failure(request, reason=""):
raised own CsrfFailure() exception to get the normal debug page on
Csrf failures.
See also:
More Info: See DocString above.
if not settings.DEBUG:
# Use original HttpResponseForbidden:
return csrf_failure(request, reason)
raise CsrfFailure("csrf failure debug: %r" % reason)
Jump to Line
Something went wrong with that request. Please try again.