Edition:
As @mipadi pointed out here (http://stackoverflow.com/questions/13001031/django-heroku-settings-injection/13092534), it can be as simple as this:
import dj_database_url DATABASES = {'default' : dj_database_url.config() }
This works if you have the enb variable DATABASE_URL set. heroku: pg_promote gets yours there. Details below
Make sure you have Postgres on your Heroku
heroku addons:add heroku-postgresql:dev
Step 1: provide the URL of your database
heroku config | grep POSTGRESQL
The result will look something like this:
HEROKU_POSTGRESQL__URL: Postgres: // user: password @ host: 5432 / blab
Step 2: Take the parameter name from the previous step (for example, HEROKU_POSTGRESQL_ROSE_URL) and put it in your settings file this way
DATABASES = {'default': dj_database_url.config(default=os.environ["HEROKU_POSTGRESQL_ROSE_URL"])}
[UPDATE] As Ted pointed out, there is a way to push a colored URL into the DATABASE_URL variable:
heroku pg:promote HEROKU_POSTGRESQL_ROSE_URL
You can use DATABASE_URL in your database settings, unlike more exotic color URLs.
DATABASES = {'default': dj_database_url.config(default=os.environ["DATABASE_URL"])}
Bob is your uncle
Philip nuzhnyy
source share