Different settings for each application with Djang

2020-06-27 05:46发布

How do I use different setting for each application?

For example:

etc...

Thanks,

3条回答
叼着烟拽天下
2楼-- · 2020-06-27 06:17

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)
查看更多
3楼-- · 2020-06-27 06:19

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

查看更多
Explosion°爆炸
4楼-- · 2020-06-27 06:41

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

查看更多
登录 后发表回答