Open VikhyatSharma17 opened 2 months ago
Log out admin users on the normal user site: You can enforce separate logins by automatically logging out the admin user when they access the normal user-facing application.
In your views.py or a middleware:
from django.contrib.auth import logout from django.urls import reverse
def user_homepage_view(request): if request.user.is_staff and not request.path.startswith(reverse('admin:index')): logout(request) # Logs out the admin user in the normal user session
When an admin session is logged in to the Django administrator dashboard and they try to open the application's homepage, the admin user shows as already logged in on the normal user application even though no login has happened.