Django 找不到设置
我有一个 Django 项目,其中包含一个“config”文件夹,其中有一个 settings_dev.py
文件,这是我的设置文件。
如果我尝试使用manage.py做任何事情,它会抱怨它找不到我的设置文件,即使我通过 --settings
选项明确提供它,例如
python manage.py syncdb --settings=config.settings_dev
Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
但是,如果我重命名我的“ config”文件夹到“设置”,它工作正常。例如
python manage.py syncdb --settings=settings.settings_dev
工作正常。
我还需要指定什么才能让它知道我的设置文件夹实际上名为 config?
I have a Django project that contains a "config" folder, which has a settings_dev.py
file inside of it which is my settings file.
If I try doing anything with manage.py, it complains that it can't find my settings file, even if I explicitly provide it via the --settings
option, e.g.
python manage.py syncdb --settings=config.settings_dev
Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
However, if I rename my "config" folder to "settings", it works fine. e.g.
python manage.py syncdb --settings=settings.settings_dev
works fine.
What else do I need to specify for it to know that my settings folder is actually named config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看manage.py。它尝试导入设置而不是conf。您必须修改您的manage.py文件
Look into manage.py. It tries to import settings not conf. You have to modify your manage.py file
在指向配置模块的项目文件夹中创建一个通用的settings.py。不要忘记 config 文件夹中的
__init__.py
。这可能比修改manage.py更好。create a generic settings.py in the project folder that points to the config module. don't forget the
__init__.py
in the config folder. This might be better than modifying manage.py.看看这个答案:
如果 settings.py 中存在导入错误,也会发生此错误。
https://stackoverflow.com/questions/6036599/bizarre-error- importing-settings-in-django#=
Have a look at this answer:
This error occurs as well if there is an import error within settings.py.
https://stackoverflow.com/questions/6036599/bizarre-error-importing-settings-in-django#=