【发布时间】:2012-06-19 18:11:01
【问题描述】:
按照这些关于添加 env 数据库设置的说明后,我正在尝试让我的本地 dev django 应用程序工作。
https://devcenter.heroku.com/articles/django-injection
我按照说明操作,但当我的应用尝试访问本地数据库时出现以下错误
Request Method: GET
Request URL: http://localhost:8000
Django Version: 1.4
Exception Type: ImproperlyConfigured
Exception Value:
You need to specify NAME in your Django settings file.
我原来的数据库设置,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db', # Or path to database file if using sqlite3.
'USER': 'foo', # Not used with sqlite3.
'PASSWORD': 'bar', # Not used with sqlite3.
'HOST': 'localhost',
'PORT': '5432',
}
}
heroku 文章说要在设置文件中添加以下内容
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
当 DATABASE_URL 在 dev 中不可用时,如何让 dj_database_url.config 使用我的 dev 设置?
【问题讨论】: