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

--

--

sanju saini
sanju saini

Written by sanju saini

Senior Software Engineer with 4.5+ years of experience in full-stack development, specializing in Python, Golang, PHP, Django, FastAPI, React, and RESTful APIs.

No responses yet