总新手在这里,抱歉
python setup.py install
安装)我正在使用this tutorial,在启动python manage.py shell
之后我跑了
>>> from django.db import connection
>>> cursor = connection.cursor()
并得到以下内容:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
我的settings.py文件的DATABASES部分如下所示:
DATABASE_ENGINE = 'django.db.backends.postgresql_psycopg2' #postgresql_psycopg2
DATABASE_NAME = 'mydatabase' #mydatabase
DATABASE_USER = 'sarahr6' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
所以我无法弄清楚为什么说它配置不当?
答案 0 :(得分:1)
您需要在settings.py
中指定DATABASES字典:
包含要使用的所有数据库的设置的字典 Django的。它是一个嵌套字典,其内容映射数据库别名 到包含单个数据库选项的字典。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydatabase',
'USER': 'sarahr6',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}