Using the excellent Django-Devserver I’m finding all kinds of interesting and unexpected SQL calls in my code. I wanted to find where the calls are coming from, and so I’m looking for a way to get a log or print-out of all SQL calls generated by the Django ORM in the Python shell. That is, when I do a Django ORM call via the Python shell, I’d like to see the resulting SQL printed out or logged.
I noticed several solutions that add log info to the html page. Is there an easy way to dump to the command line instead?
If you’re in the shell, or anywhere for that matter, you can use the queryset method
to print the SQL command.
ie: