根据多个站点的请求动态更改Django设置变量 [英] Changing Django settings variable dynamically based on request for multiple site

查看:103
本文介绍了根据多个站点的请求动态更改Django设置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请咨询是否正确的方法是根据所请求的站点在自定义中间件功能中动态更改django设置文件的urlconf和templatedir变量。

Please advice whether is it correct method to change the urlconf and templatedir variables of a django settings file dynamically within a custom middleware function based on the site requested.

推荐答案

否。我不知道你为什么要这样做。如果您有多个网站,正确的方式可以使用多个WSGI实例,每个实例都指向不同的settings.py和urls.py文件。

No. I don't know why you would want to do this. If you have multiple sites, the correct way to serve them is with multiple WSGI instances, each pointing at separate settings.py and urls.py files.

注释后编辑:这与网站框架无关,这是完全可选的。正如我所说,如果你想要服务多个网站,请使用多个 .wsgi 脚本,每个脚本指向一个单独的 urls.py settings.py 。所有其余的代码可以相同。

Edit after comment: This has nothing to do with the sites framework, which is completely optional. As I say, if you want to serve multiple sites, use multiple .wsgi scripts each pointing to a separate urls.py and settings.py. All the rest of the code can be the same.

这篇关于根据多个站点的请求动态更改Django设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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