简体   繁体   中英

How to use same django project multiple times - each with diffrent database?

I wrote a django project that is some kind of a CMS. Now, I want to be able to create several accounts that use that CMS, Each with a different database. For example, user can create himself an account in my service - and he will get a site based of that CMS. How can I get started doing this?

Unfortunately Django is not suited to dynamically switch databases at runtime. You either have to implement really hackish solutions (like mentioned in this question Django multiple and dynamic databases ) or to go with several independent Django instances which you will have to start up on your server dynamically.

A much simpler solution would be to stick to one database and distinguish different users' content by some other means, like Django Sites framework . The only problem with this approach in my opinion is that you will have to carefully set up your admin site configuration, so that users don't see each other's objects (in case you planned to use built-in Django admin).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM