Django SQL Tracing Middleware

2013 Jan07
T
here are a number of tools within the Django framework itself as well as he community for inspecting all of the SQL [Django](http://djangoproject.com) is executing. The [Debug Toolbar](http://github.com/django-debug-toolbar/django-debug-toolbar) has be come the defacto standard in that respect. However, most all, if not all of the usual suspects are relying on template tags and rendered html templates / javascript to read the debug information. All fine and good, unless you are building an ajax application that never renders html or makes use of the template hooks.

The simple solution to this problem is to write a middleware class to spit out the sql generated by the database connection for the current request. And

Read More
filed under:  django ansi tracing middleware sql