开发者

Different settings for each application with Django

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 u开发者_运维技巧ses the settings.py + local_settings.py of the app2's folder...

etc...

Thanks,


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


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


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)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜