I’m trying to configure local dev environment with Heroku, Django and virtualenv. Everything seems to be working when pushed to Heroku hosting, but locally, I cannot seem to connect to the Heroku-supplied dev Postgre DB.
According to the instructions, I added the following to settings.py:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
But this doesn’t seem to get invoked while running locally. Get the following exception:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
Is it even possible to connect to the Heroku hosted dev Postgre from a local instance of Django? If it is, what am I missing?
Thank you!
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:
Same steps work if you are using a local Postgre setup as well.