[Django]-How to configure Django to use Heroku Dev Postgre while local?

3👍

This turned out to be relatively straightforward…

dj_database_url.cofig() takes a parameter default. Database info on heroku can be found here:
https://postgres.heroku.com/databases/

If your db info and credentials are as follows:
Host somehost.amazonaws.com
Database somedb
User foo
Port 5432
Password bar

Then the settings.py entry should look like this:

import dj_database_url
DATABASES['default'] =  dj_database_url.config(default='postgres://foo:bar@somehost.amazonaws.com:5432/somedb')

Same steps work if you are using a local Postgre setup as well.

Leave a comment