public
Last active

Django SQL dump middleware

  • Download Gist
sqldump_middleware.py
Python
1 2 3 4 5 6 7 8 9
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.