[Answered ]-How to show the sql django runs?

2👍

In debug mode, you could use django-debug-toolbar, it prints all SQLs executed, as well as callees and explains of the SQLs, and extra info such as templates invoking, request, signals, etc. Very handy indeed.

In shell, as Yuji Tomita suggests, print queryset.query (in legacy Django it’s something like queryset._get_sql_clause(), just FYI) or connection.queries in your question.

👤okm

Leave a comment