I\'d like to switch databases upon user login. I\'ve created this login signal.. but it doesn\'t work
from django.dispatch import receiver
from django.contrib.au
It's the wrong way of doing it.
Honestly I don't think there is a straightforward, stable way of doing this in Django. It's just not designed for it.
Instead, I'd set up a settings_username
.py file for each user, which specifies a secondary database called personal or something. Then, after logging, have them redirect to a new domain, like username
.example.com, which uses a unique .wsgi file that pulls in the settingsusername
.py file.
Now, as far as the system is concerned, each website is totally separate and unique to that user. Just make sure to set the session cookie to example.com so that they're still logged in when they go to their user website.