Django database router

前端 未结 2 1537
北荒
北荒 2020-12-21 21:01

I\'d like to route (change) the database based on the authenticated user. I\'ve looked at the docs but I don\'t know how to do this upon user login...

I was thinking

2条回答
  •  我在风中等你
    2020-12-21 21:49

    Multitenancy in general is a little bit hard to do without twisting django a bit, even though it is a typical request in SaaS applications. Here is a link describing one approach, the one developed at a company I worked with was a little bit different, hacking the contrib.sites, but the database part is pretty similar.

    In short, if you want database multitenancy you are going to have to hack Django ConnectionHandler to do what you want.

提交回复
热议问题