0

これは、python manage.py syncdb を実行すると発生します。python manage.py syncdb --mysite.settings を実行したときにも発生します。ここからどこに行けばよいかわからない: django が設定ファイルを認識せず、その理由や修正方法がわかりません。

python ../manage.py syncdb
Traceback (most recent call last):
  File "../manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
    cursor = connection.cursor()
  File "/home/ryan/Programming/OpenCV-2.4.2/msheroku/venv/local/lib/python2.7/site-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 から

DATABASES = { 
    'default': {
        'ENGINE': 'postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'xxx',                      # Or path to database file if using sqlite3.
        'USER': 'xxx',                      # Not used with sqlite3.
        'PASSWORD': 'xxx',                  # 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.
    }   
}

そもそも正しい設定ファイルが見つからないことは確かです。

4

2 に答える 2

4

こんにちは、heroku を使用してアプリをテストしていて、ローカル データベースに接続しようとしていると思いますか? その場合は、次のコード行を必ず削除してください。

# Parse database configuration from $DATABASE_URL
  import dj_database_url
  DATABASES['default'] =  dj_database_url.config()

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
  SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Anther サーバー上のデータベースに接続するときに追加します。

于 2013-05-07T15:05:19.513 に答える
0

正しいものは次のようになります。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

編集:コメントとmanage.pyを反映するために、ホストをlocalhostに変更しました

syncdb の実行方法に基づいて

python manage.py syncdb --mysite.settings

manage.py ファイルに正しい DJANGO_SETTINGS_MODULE が指定されていることを確認してください

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

--mysite.settings なしで syncdb を実行できるはずです。

python manage.py syncdb
于 2013-01-24T13:30:25.940 に答える