spence91 spence91 - 3 years ago 111
SQL Question

Show the sql Django is running?

Is there a way to show the SQL that Django is running while performing a query?

Answer Source

Try the docs FAQ: How can I see the raw SQL queries Django is running?

django.db.connection.queries contains a list of the SQL queries.

from django.db import connection
print connection.queries

Querysets also have a query attribute containing the query to be executed.

print MyModel.objects.filter(name="my name").query
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download