单个Django项目下的多个站点 [英] Multiple Sites under single Django project

查看:364
本文介绍了单个Django项目下的多个站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单个django项目下有多个站点是可能和正确的。这样就可以将全局共享的文件,URL文件以及所有站点的全局共享应用程序以及单个django项目下的所有站点的通用管理界面。每个网站可能都有自己的设置,网址和模板,将被覆盖或动态导入父设置文件。



有人可以告诉我如何使用Python2 .6 + Django 1.2.1 + Apache2.2 + mod_wsgi。由于我在使用mod_wsgi时需要提供virtualhost,所以我有点困惑。



根据上述要求,我计划将wsgi文件保存在主要的django项目目录中,以便主要的设置将被导入,并在我计划的主要环境中动态导入所请求的站点设置。这可能使用Apache + mod_wsgi。请咨询。





而不是全局django项目,我必须制作一个全球共享模块进行导入全局设置和URL详细信息到站点特定设置和网址。



我想更好地重用代码,而不是在每个站点进行冗余更改。 >

请咨询。

解决方案

是的,这是完全可能的。这些网站甚至可以共享数据。



网站框架可以实现这一点 - 有关文档,请参阅这里:



http:// docs .djangoproject.com / en / 1.2 / ref / contrib / sites


Is it possible and correct to have multiple sites under single django project. So that there will be globally shared sittings file,urls files along with global shared 'apps' for all the sites and a common admin interface for all the sites under the single django project. Each site might have its own setting,urls and templates that will be overridden or imported dynamically into the parent settings file.

Could anyone please tell me how to achieve this using Python2.6 + Django 1.2.1 + Apache2.2 + mod_wsgi. As I am a bit confused with the virtualhost need to be supplied while using the mod_wsgi.

As per the above requirement I am planning to keeping the wsgi file in the main django project directory so that the main settings will be imported and within the main setting I am planning to import the requested sites settings dynamically.Is it possible this way using Apache + mod_wsgi. Please advice.

OR

Instead of global django project do I have to make a globally shared module for importing the global setting and url details into site specific settings and urls.

I would like to make better reuse of the code rather than making redundant changes in each sites.

Please advice.

解决方案

Yes, this is entirely possible. The sites can even share data.

The sites framework enables this - for documentation, see here:

http://docs.djangoproject.com/en/1.2/ref/contrib/sites

这篇关于单个Django项目下的多个站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆