Search code examples
djangodatabasedjango-ormdjango-debug-toolbar

extra query after logging in to the site (django3.2)


Why after logging in to the site, an extra query is taken on all pages to get that user information? Is this related to Django it self? Or can this extra query be deleted and optimized?

What the Django-debug-toolbar shows on all pages:

SELECT ••• FROM "accounts_user" WHERE "accounts_user"."id" = '1' LIMIT 21

And the user with the id=1 is the user I logged in with.


Solution

  • This is how Django make 'request.user' available all the time, so there is nothing you can do, if you want to use Django Authentication System.