How to find the query associated with a queryset..?

sanju saini
May 27, 2021

Sometimes you want to know how a Django ORM makes our queries execute or what is the corresponding SQL of the code you are writing. This is very straightforward. Youn can get str of any queryset. query to get the SQL.
You have a model called Enquiry. For getting all records, you will write something like queryset =Enquiry.objects.all(),
then do str(queryset. query)

For Example

--

--