How to display SQL QUERY before execute it #456
-
How to display the SQL Query before execute it, or somewhere between a sequence of filters. My query is failing for KeyError, and I can't find exactly where. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
In Django there's a very helpful print(Model.objects.filter(field="value").query) would print something like: SELECT * FROM `model` WHERE field ="value"; Having the possibility to have something like that in |
Beta Was this translation helpful? Give feedback.
Right now it's not possible in a clean way (unless
databases
have debug option, didn't check).I will probably introduce one myself as for now in a need like this I revert to ugly printed 🤣
If you execute a select you can uncomment line 277 in
queryset.py
:If you use prefetch_related same in prefetch_query line 506