how to modularize django settings.py?

后端 未结 8 743
礼貌的吻别
礼貌的吻别 2020-12-13 19:46

When you install a new django application, you have to add/modify your settings.py module.

For a project I\'m trying to make that module a python subpackage and crea

8条回答
  •  清歌不尽
    2020-12-13 20:21

    I've used this work-around:

    settings.py:

    INSTALLED_APPS = ('whatever',)
    import more_settings
    more_settings.modify(globals())
    

    more_settings.py:

    def modify(settings):
        settings['INSTALLED_APPS'] += ('another_app',)
    

提交回复
热议问题