Comment voir les requêtes SQL brutes exécutées par Django?
snippet in sql

Comment voir les requêtes SQL brutes exécutées par Django?

user5289

from django.db import connection
print(connection.queries)

Comment voir les requêtes SQL brutes exécutées par Django?

user3866

./manage.py shell_plus --print-sql
User.objects.get(pk=1)
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"
WHERE "auth_user"."id" = 1

Execution time: 0.002466s [Database: default]

<User: username>