You print the queryset's query attribute.
query
>>> queryset = MyModel.objects.all() >>> print(queryset.query) SELECT "myapp_mymodel"."id", ... FROM "myapp_mymodel"
2.1m questions
2.1m answers
60 comments
57.0k users