You print the queryset's query attribute.
query
>>> queryset = MyModel.objects.all() >>> print(queryset.query) SELECT "myapp_mymodel"."id", ... FROM "myapp_mymodel"
1.4m articles
1.4m replys
5 comments
57.0k users