Django/Heroku Settings injection?

烂漫一生 提交于 2019-12-12 04:46:44

问题


I want to be able to change my DATABASES['default'] setting to change automatically when I deploy to heroku. Is there some way to do this?

This looks like what I want https://devcenter.heroku.com/articles/django-injection, but it seems like it no longer works as of July 1, 2012.


回答1:


Use dj_database_url, as described here. To wit:

$ pip install dj-database-url

and then in settings.py:

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

You can pass config a default argument if you don't want to set DATABASE_URL locally. More info is available here.



来源:https://stackoverflow.com/questions/13001031/django-heroku-settings-injection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!