由于大多数评论已经暗示您可以from module import *
在适当的文件中使用。它们可能如下所示..
--
# settings/common.py
DEBUG = False
--
# settings/configs/constants1.py
CONSTANT_1 = 'One'
--
# settings/configs/constants2.py
CONSTANT_2 = 'Two'
--
# settings/debug/include1.py
from settings.common import *
from settings.configs.constants1 import *
# Override settings here
DEBUG = True
CONSTANT_1 = '1'
--
# settings/debug/include2.py
from settings.common import *
from settings.configs.constants2 import *
# Override settings here
DEBUG = True
CONSTANT_2 = '2'
并且对于 2 调试的组合包括
# settings/debug/include1and2.py
from settings.debug.include1 import *
from settings.debug.include2 import *
或者
# settings/debug/include1and2.py
from settings.common import *
from settings.configs.constants1 import *
from settings.configs.constants2 import *
# Override settings here