Created
September 20, 2011 17:12
-
-
Save kesor/1229685 to your computer and use it in GitHub Desktop.
Django SQL dump middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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