Django multitenancy

I'm working on a SaaS project using Django Tenants and I'm having trouble maintaining the user session when redirecting to a subdomain. My configuration: Custom User model: CustomUser (in an application account located in SHARED_APPS). Business logic: The Tenant model has a OneToOne relationship with CustomUser. Authentication flow: The user logs in to the primary domain (localhost:8000). The backend authenticates the user via login(request, user). I retrieve their associated domain and redirect to http://tenant1.localhost:8000. The problem: Once redirected to the subdomain, the user is considered anonymous (AnonymousUser). The session doesn't seem to be passed or recognized between the primary domain and the subdomain. What I've already configured in settings.py: # Disabling secure for local development (HTTP) SESSION_COOKIE_SECURE = False CSRF_COOKIE_SECURE = False SESSION_COOKIE_SAMESITE = 'Lax' My question: Is there a specific configuration for django-tenants or session middleware that I might have missed to ensure the session cookie is valid across all my schemas/domains? Thanks in advance for your help!

Вернуться на верх