Skip to content

Instantly share code, notes, and snippets.

@kesor
Created September 20, 2011 17:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kesor/1229685 to your computer and use it in GitHub Desktop.
Save kesor/1229685 to your computer and use it in GitHub Desktop.
Django SQL dump middleware
from django.conf import settings
from django.db import connection
class SqldumpMiddleware(object):
def process_response(self, request, response):
if settings.DEBUG and 'sqldump' in request.GET:
response.content = str(connection.queries)
response['Content-Type'] = 'text/plain'
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment