Search code examples
djangoauthenticationsessiondjango-admin

How to prevent django admin login and logout sessions from reflecting in actual website?


I'm quite new to django.

I've made a website that makes use of user auth for login, logout and registration.

Whenever I log into the admin panel, it also gets reflected in the actual website. The admin account gets logged into the website on its own.

I know this is the default behaviour of the django auth system, but I want to separate the auth session of admin panel and the actual website.

How can I do so?

The screenshots below show the thing which I'm talking about.

👇 Here I've logged into the Admin panel.

admin panel

👇 The Admin account got logged into the website on its own by using the admin session..

website home page

I just want that both admin panel and website should have separate auth sessions and shouldn't be linked to each other.

The website is hosted online here

Thanks in advance!


Solution

  • You could write middleware for this, to explicitly logout authenticated users in non-admin pages as suggested in this answer:

    https://stackoverflow.com/a/57357586/2135738