How to see the generated SQL statements when running Django.server configuration
Answered
I'm troubleshooting a Django project, and it runs in PyCharm IDE as a Django.server configuration.
I suspect a class of admin.ModelAdmin has low-efficient inlines, and want to see the SQL statements generated by Django as the application runs and proceeds with testing operation.
Inputs will be highly appreciated, and let me know if you need more information. Thank you.
Please sign in to leave a comment.
I don't think it's related to PyCharm directly. PyCharm has no special feature for that so it's something you should do on the code side.
Take a look at similar threads:
https://stackoverflow.com/questions/1074212/how-can-i-see-the-raw-sql-queries-django-is-running
https://stackoverflow.com/questions/2314920/django-show-log-orm-sql-calls-from-python-shell
https://kiennt.com/blog/2012/10/25/django-show-sql-query-in-shell.html
Sergey Karpov Thank you for the reply. Yes, you're right.
Show SQL is not a PyCharm specific feature, and I was able to make it work by modifying source code following the link below:
https://stackoverflow.com/questions/4375784/log-all-sql-queries