“settings.DATABASES被不正确地配置”使用django 1.4执行syncdb时出错 [英] "settings.DATABASES is improperly configured" error performing syncdb with django 1.4
问题描述
我创建了一个简单的django 1.4项目,并尝试发出syncdb来创建(postgres)数据库模式。我收到这个错误: -
I've created a simple django 1.4 project and am trying to issue syncdb to create the (postgres) db schema. I'm getting this error :-
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured.Please supply the ENGINE value. Check settings documentation for more details.
我的settings.py文件看起来像: -
My settings.py file looks like :-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'test', # Or path to database file if using sqlite3.
'USER': 'test', # Not used with sqlite3.
'PASSWORD': 'test', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
我可以使用psql连接到数据库OK - 任何想法?感谢提前!
I can connect to the database using psql OK - any ideas ? Thanks in advance !
推荐答案
可能是django没有访问你认为它使用的settings.py文件。
尝试使用--settings明确指向django到您的设置文件
It might be that django is not accessing the settings.py file you think it uses. Try explicitly point django to your settings file by using --settings
./manage.py --settings=nameofproject.settings runserver/syncdb
如果这样工作,那么你必须弄清楚为什么django是导入错误的设置文件。
If this works then, you'll have to figure out why django is importing the wrong settings file.
您是否意外从1.3升级到1.4?
Have you upgraded from 1.3 to 1.4 by accident ?
这篇关于“settings.DATABASES被不正确地配置”使用django 1.4执行syncdb时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!