开发者

Django, dynamic apps support

开发者 https://www.devze.com 2023-01-17 00:47 出处:网络
I am about to start a django project, where I need a base deployment, lets say just for admins initially. Later admins can add instances of my main public site.

I am about to start a django project, where I need a base deployment, lets say just for admins initially. Later admins can add instances of my main public site.

Now, one instance will, obviously be separated by dynamic sub-domains. I need to capture sub-domains from requests, and compute accordingly. It has its own base templates, static files, etc (easiest part). It would have set of feature apps (common for all instances, but not the data in their models). And I am thinking of using Django1.2's multiple database support, and try to get one db per instance (* adding dynamically :( , if that is feasible, It will include开发者_如何学Python dynamic db/model creations*). Or I can go for adding an instance foreign_key in all feature apps models, to separate them instant-wise.

If my instances were known prior to deployment, I would have used multiple database support easily by capturing the sub-domains and diverting my ORM calls to concerned db. But, that is not the case. Those has to be dynamic (added as need arises).

Now before I give it a try, to get solution/rid of delusions about it, I would want experts of SO to think about it. I would appreciate the suggestions, insights and of-course criticism.

I can make it community wiki, if suggested. Thanks guys.


Shouldn't you just run a separate Django instance in a each their Apache VirtuaHost? Then, you can have a Django settings file for each instance and they can each point at their proper database. This also simplifies your code because you don't need to map subdomain names to databases inside your views. As a real bonus, your code gets re-usable because it doesn't depend on your complex setup.


Ususally you can do instances of your app with the sites framework.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号