Different settings for each application with Django

我只是一个虾纸丫 提交于 2019-12-05 05:35:59

问题


How do I use different setting for each application?

For example:

  • http://www.mysite.com/app1 uses the settings.py + local_settings.py of the app1's folder...

  • http://www.mysite.com/app2 uses the settings.py + local_settings.py of the app2's folder...

etc...

Thanks,


回答1:


you could check all ways of splitting up your settings from here: https://code.djangoproject.com/wiki/SplitSettings




回答2:


Older relevant thread talking about per application settings:

http://groups.google.com/group/django-developers/browse_thread/thread/fc8b2e284459f6cf

You can run multiple django instances on a single domain with different settings using the advice from here:

multiple instances of django on a single domain




回答3:


It's not pretty, but you can put the following in your settings.py after INSTALLED_APPS:

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
for app in INSTALLED_APPS:
    local_settings = os.path.join(PROJECT_DIR, app, 'local_settings.py')
    if os.path.isfile(local_settings):
        execfile(local_settings)


来源:https://stackoverflow.com/questions/5410294/different-settings-for-each-application-with-django

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!