开发者

Changing Django settings variable dynamically based on request for multiple site

开发者 https://www.devze.com 2023-01-09 22:34 出处:网络
Please advice whether is it correct method t开发者_开发问答o change the urlconf and templatedir variables of a django settings file dynamically within a custom middleware function based on the site re

Please advice whether is it correct method t开发者_开发问答o change the urlconf and templatedir variables of a django settings file dynamically within a custom middleware function based on the site requested.


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.

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.

0

精彩评论

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