from django.db import connection from django.template import Template, Context class SQLLogMiddleware: """ http://www.djangosnippets.org/snippets/161/ To enable, add the following line to your settings.py: MIDDLEWARE_CLASSES += ('DjHDGutils.profiling.SQLLogMiddleware',) """ def process_response ( self, request, response ): time = 0.0 for q in connection.queries: time += float(q['time']) if response['Content-type'].find('text/html')==-1: return response t = Template(u'''
Total query count: {{ count }}
Total execution time: {{ time }}