Answer the question
In order to leave comments, you need to log in
How to get raw DB query when we get data by Model.objects....?
Good evening. The question has ripened that I want to look under the hood of some functions. Now I want to know which django generates a query to the database when we select data, filter, sort, merge, etc. Is it possible to display this information somehow?
Answer the question
In order to leave comments, you need to log in
If a QuerySet is returned (and not an object, as in the case of .first or .get), then QS has a .query attribute
str(Model.objects.filter(...).values_list(...).query)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question