1

我是 Heroku / Django / Postgres 游戏的新手,在按照他们教程中的说明操作后遇到了麻烦。这是我的设置:

已安装:Django 1.4.5 dj_database_url Postgress.app 9.2.2.0

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

稍后在 settings.py 中:

import dj_database_url
    DATABASES['default'] = dj_database_url.config()

当我运行 python manage.py syncdb 时:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
   execute_from_command_line(sys.argv)
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-         packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
  File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
  File "/Users/joerobinson/.virtualenvs/dg/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.

当我运行 python manage.py shell、导入设置并查看 DATABASES 时,我得到:

{'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD':

所以我知道我一定是配置不正确,但是经过一夜的搜索,我还没有找到正确的设置。有人见过这个吗?

4

3 回答 3

1

您可能想要一个真正的 Django 数据库后端,而不是django.db.backends.dummy. 例如:

{'ENGINE': 'django.db.backends.postgresql_psycopg2', ... }
于 2013-02-26T08:40:04.820 回答
0

我不得不点配置数据库 URL,如下所示:

DATABASES['default'] = dj_database_url.config(default='postgres://localhost/db_name')

我遇到了与 psycopg2 包和 gcc-4.2 相关的其他问题,但我的原始帖子并未涵盖这些问题。

于 2013-03-11T02:41:16.297 回答
0

我通过删除 dummy/base.py 并为其创建符号链接解决了同样的问题:

ln -s /usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py /usr/lib/python2.6/site-packages/django/db/backends/dummy/base.py
于 2013-07-28T08:19:24.253 回答