我是一个完整的Heroku菜鸟,我正在尝试在Heroku上设置一个Django应用程序.我无法弄清楚在settings.py中输入这些设置的内容:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': '',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮帮我吗?谢谢!
And*_*ter 20
您可以通过在仪表板中查看数据库信息或运行"heroku config"来查看数据库配置字符串来手动执行此操作.但到目前为止最好的方法是在Django的Heroku入门指南中详细介绍.添加dj-database-url==0.2.1到您的requirements.txt文件,然后:
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Run Code Online (Sandbox Code Playgroud)
代替其他数据库定义.
| 归档时间: |
|
| 查看次数: |
8907 次 |
| 最近记录: |