I configured my database in Heroku several months ago so don't remember exact steps I took. I'm using the Heroku-Postgres add-on: https://devcenter.heroku.com/articles/heroku-postgresql
I have a DATABASE_PASS
listed as a config var in Heroku. And I have a config var for DATABASE_URL
In my settings.py
file I only have the following as it relates to my database. Why is my app still working in production on Heroku if DATABASES
variable is referring to localhost only?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'my_dev',
'USER': 'postgres',
'PASSWORD': os.environ.get('DATABASE_PASS'),
'HOST': 'localhost',
'PORT': '5410',
}
}
The Heroku-Postgres documentation states the following:
The value of your app’s DATABASE_URL config var might change at any time. You should not rely on this value either inside or outside your Heroku app.
Am I doing something wrong? Should I not rely on DATABASE_URL
as a config var?
Additional Detail - I am using the django-heroku
pip package.
Why is my app still working in production on Heroku if
DATABASES
variable is referring to localhost only?Additional Detail - I am using the
django-heroku
pip package.
django-heroku
does quite a lot, including setting up your database from the DATABASE_URL
environment variable automatically:
This will automatically configure
DATABASE_URL
,ALLOWED_HOSTS
, WhiteNoise (for static assets), Logging, and Heroku CI for your application.