Changing Django settings variable dynamically based on request for multiple site
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.
精彩评论