how to modularize django settings.py?

后端 未结 8 751
礼貌的吻别
礼貌的吻别 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:07

    I have the same structure of settings files and I do the following to import the settings of the submodules:

    def load_settings_file(file):
        file = open(os.path.join(INSTALL_DIR, '', 'settings', file + '.py'))
        content = file.read()
        file.close()
        return content
    
    for submodule in ['base', 'admin', 'feincms']:
        exec(load_settings_file(submodule))
    

提交回复
热议问题