Skip to content

Instantly share code, notes, and snippets.

@timonweb
Forked from kesor/sqldump_middleware.py
Created May 23, 2012 07:45
Show Gist options
  • Save timonweb/2773750 to your computer and use it in GitHub Desktop.
Save timonweb/2773750 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