【发布时间】:2023-04-07 15:14:01
【问题描述】:
我有这样的文件布局:settings/----__init__.py----common.py----configs/--------constants1.py--------constants2.py----debug/--------include1&2.py--------include1.py--------include2.py
当我导入settings.debug.include1 时,我希望设置文件执行/导入common.py 然后用适当的常量文件覆盖common.py 中的设置。问题是,这没有发生。有没有办法以这种方式实现我的目标?
【问题讨论】:
-
“指定
settings.debug.include_.py”是指import settings.debug.include1吗? -
哦,在使用设置的代码中,您想说
from settings import *并始终检索正确的设置集? -
好吧,您可以将决定加载哪组设置的逻辑放入 common.py 并从那里导入适当的调试/配置模块。
标签: python django import settings