I'm working on a similiar solution, where we have a django application which needs multi-tenancy so I'm creating new DB for each tenant and switching to that DB as the request comes in, this is a temporary solution we came up with due to the open source application we are dealing with, which has so many modification if we want to change the core to support multi-tenancy.
So I want to switch to new DB or create the db and switch to that db once the user is authenticated, and use that db for the authenticated user.
Can anyone give how to approach to it?
I'm planning on creating middleware to intercept the request and change the DB context. Also there is a function in an context which is called to get the db connection name, there also I'm changing it to user's DB.
I want to know where all should I change and what are the aspects I should look for?