how to modularize django settings.py?

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

    just put

    from base import *
    from admin import *
    ...
    

    in ur init.py that should work

    i used it for different sites

    base/settings.py # common settings: db, apps, ...
    base/sites/website1/settings.py # site_id, custom middleware 
    base/sites/website2/settings.py # site_id, custom middleware
    

    the website settings import the common settings with

    from base.settings import *
    

    and define custom attribtues

提交回复
热议问题