【发布时间】:2016-03-30 07:04:54
【问题描述】:
所以我有一个完成的 Django 应用程序,我现在正尝试将它上传到 Heroku 以投入生产,尽管我遇到了一些问题。我一直在关注 Heroku 网站上的教程:
https://devcenter.heroku.com/articles/django-app-configuration#migrating-an-existing-django-project
虽然我遇到了这个错误:
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
听起来我需要将我的数据库上传到 S3 以便 Heroku 可以访问它,所以我在本教程中这样做了
https://devcenter.heroku.com/articles/heroku-postgres-import-export#import
但我仍然收到错误消息。这是我的一些设置。
Settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'texchange',
'USER': 'joe',
'PASSWORD': '#######',
'HOST': 'localhost',
'PORT': '',
}
}
STATICFILES_DIRS = (
('/static/',
'/home/joe/Documents/exchange/Texchange/textchange/static/',),
('/media/',
'/home/joe/Documents/exchange/Texchange/textchange/media/'),
)
MEDIA_ROOT = '/home/joe/Documents/exchange/Texchange/textchange/media/'
MEDIA_URL = '/media/'
STATIC_ROOT = '/home/joe/Documents/exchange/Texchange/textchange/static/'
STATIC_URL = '/static/'
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
# Enable Persistent Connections
DATABASES['default']['CONN_MAX_AGE'] = 500
我到底不明白什么?任何方向都将不胜感激,因为这是我第一次使用 Heroku 和 S3 上传应用程序。
【问题讨论】:
-
发布您在 Heroku 管理员中设置的
DATABASE_URL -
现在它是它开始的默认值。我尝试将其设置为我上传到 S3 的转储文件,但出现错误:DATABASE_URL 无效。必须采用 FOO=bar 格式。
-
Heroku 似乎没有找到您的设置,因为您显然已经在您发布的代码中配置了引擎。你能显示你的 Procfile,以及显示 settings.py 所在位置的文件布局吗?
-
这就是我的 Procfile 中的全部内容: web: gunicorn exchange.wsgi --log-file -
-
只有当我运行“Heroku local”时才会出现数据库错误。
标签: python django postgresql heroku