Skip to content

Exempt SQL Detail Views from CSRF Middleware #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions debug_toolbar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.shortcuts import render_to_response
from django.utils import simplejson
from django.utils.hashcompat import sha_constructor
from django.views.decorators.csrf import csrf_exempt

class InvalidSQLError(Exception):
def __init__(self, value):
Expand All @@ -26,6 +27,7 @@ def debug_media(request, path):
root = os.path.join(parent, 'media', 'debug_toolbar')
return django.views.static.serve(request, path, root)

@csrf_exempt
def sql_select(request):
"""
Returns the output of the SQL SELECT statement.
Expand Down Expand Up @@ -58,6 +60,7 @@ def sql_select(request):
return render_to_response('debug_toolbar/panels/sql_select.html', context)
raise InvalidSQLError("Only 'select' queries are allowed.")

@csrf_exempt
def sql_explain(request):
"""
Returns the output of the SQL EXPLAIN on the given query.
Expand Down Expand Up @@ -98,6 +101,7 @@ def sql_explain(request):
return render_to_response('debug_toolbar/panels/sql_explain.html', context)
raise InvalidSQLError("Only 'select' queries are allowed.")

@csrf_exempt
def sql_profile(request):
"""
Returns the output of running the SQL and getting the profiling statistics.
Expand Down Expand Up @@ -141,6 +145,7 @@ def sql_profile(request):
return render_to_response('debug_toolbar/panels/sql_profile.html', context)
raise InvalidSQLError("Only 'select' queries are allowed.")

@csrf_exempt
def template_source(request):
"""
Return the source of a template, syntax-highlighted by Pygments if
Expand Down