1 2 3 4 5 6 | import sqlparse
def print_sql(qs):
q = qs.query.as_sql()
statement = q[0] % q[1]
print sqlparse.format(statement, reindent=True, keyword_case='upper')
|
More like this
- A custom URL shortening view, for use with rev=canonical by simon 4 years, 2 months ago
- Git recent commits template tag by david 4 years, 10 months ago
- Add Extra Headers to Test Client Requests by luftyluft 4 years, 11 months ago
- QuerySetManager - easily add new QuerySet methods using a Model inner class by simon 5 years, 1 month ago
- Fire Eagle example: views.py from wikinear.com by simon 5 years, 3 months ago
Comments
You might want to wrap this with something so that this doesn't get used in non-development mode. For example:
#
This should work in Django 1.2:
#