Django / Heroku设置注入? [英] Django/Heroku Settings injection?
本文介绍了Django / Heroku设置注入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要将我的DATABASES ['default']设置更改为在部署到heroku时自动更改。有没有办法这样做?
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?
这看起来像我想要的
https://devcenter.heroku.com/articles/django-injection ,但似乎它不再适用于2012年7月1日。
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.
推荐答案
使用 dj_database_url
,如 here 。要想:
$ pip install dj-database-url
然后在 settings.py
中:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
如果您不想设置<$ c $,则可以通过 config
a default
参数c> DATABASE_URL 本地。更多信息可以此处。
You can pass config
a default
argument if you don't want to set DATABASE_URL
locally. More info is available here.
这篇关于Django / Heroku设置注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文