Django SQL Tracing Middleware

2013 Jan08
T

here are a number of tools within the Django framework itself as well as he community for inspecting all of the SQL Django is executing. The 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 of course some color coding to make it

Read More
filed under:  django ansi tracing middleware sql