see sql code generated by django models code example
Example 1: Django print query
print(MyModel.objects.filter(name="my name").query)
Example 2: Django print query
from django.db import connection
print(connection.queries)
print(MyModel.objects.filter(name="my name").query)
from django.db import connection
print(connection.queries)