我是Heroku / Django / Postgres游戏的新手,在按照tutorial中的说明操作后遇到了麻烦。这是我的设置:
安装: 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':
所以我知道我必须配置不正确的东西,但是我没有在搜索的夜晚找到正确的设置。有人见过这个吗?
答案 0 :(得分:1)
您可能想要一个真正的Django数据库后端,而不是django.db.backends.dummy
。例如:
{'ENGINE': 'django.db.backends.postgresql_psycopg2', ... }
答案 1 :(得分:0)
我必须按如下方式配置数据库URL:
DATABASES['default'] = dj_database_url.config(default='postgres://localhost/db_name')
我还有其他与psycopg2软件包和gcc-4.2有关的问题,但我原来的帖子没有涵盖这些问题。
答案 2 :(得分: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