查看Django ORM 执行的SQL语句

In[2]: from django.contrib.auth.models import User
In[3]: User.objects.all()[0]
Out[3]: 
In[4]: from django.db import connection
In[5]: connection.queries
Out[5]: 
[{'sql': 'SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" LIMIT 1',
  'time': '0.000'}]

你可能感兴趣的:(查看Django ORM 执行的SQL语句)