2011-01-23 26 views
0

我想创建一个模块化设置文件。从模块化django设置文件导入错误

为什么说这个工程:

project/ 
    settings.py 
    other.py 

这条线在settings.py

config_module = __import__('other', globals(), locals()) 

虽然下面提出了一个ImportError:

project/ 
    settings.py 
    config/ 
    other.py 

有了这条线settings.py:

config_module = __import__('config.other', globals(), locals()) 
+1

你是否缺少配置目录中的__init __。py`? – 2011-01-23 19:22:55

回答

2

看起来像您的配置目录缺少一个__init__.py文件,以清楚地表明您希望它被视为模块。 __init__.py文件可以是空的,但它需要存在。