1

まったくの初心者です、すいません

  • Mac OSX 10.8 Python 2.7 (自作でインストール)
    • PostgreSQL 9.4(自作でインストール)
    • psycopg2 2.5 (macports でインストール)
    • Django 1.0.4 (経由でインストールpython setup.py install)

私はこのチュートリアルを使用しています。開始後、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.

では、なぜそれが不適切に構成されていると言われているのかわかりませんか?

4

1 に答える 1

1

でDATABASESディクショナリを指定する必要がありますsettings.py:

Django で使用するすべてのデータベースの設定を含む辞書。これは、ネストされたディクショナリであり、その内容はデータベース エイリアスを個々のデータベースのオプションを含むディクショナリにマップします。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydatabase',
        'USER': 'sarahr6',
        'PASSWORD': '',
        'HOST': '',
        'PORT': ''
    }
}
于 2013-08-19T20:52:56.923 に答える