Closed
Description
While https://github.com/heroku/python-getting-started/blob/main/gettingstarted/settings.py says
`DATABASE_URL` will be set automatically by Heroku when a database addon is attached to your Heroku app.
in actual fact this wasn't true in my case. The variable was called HEROKU_POSTGRESQL_GREEN_URL
I expect that future noobie users will be assisted if the example calls out the variability in the naming of the DATABASE_URL
environment variable and shows how to discover what it is called and how to incorporate the actual name.
Something like this:
if IS_HEROKU_APP:
# In production on Heroku the database configuration is derived from a `DATABASE_URL`
# environment variable by the dj-database-url package. `DATABASE_URL` or a similar color variable will be set
# automatically by Heroku when a database addon is attached to your Heroku app.
# Run 'heroku config' to find the name of your `DATABASE_URL` and update the code below. See:
# https://devcenter.heroku.com/articles/provisioning-heroku-postgres
# https://github.com/jazzband/dj-database-url
DATABASES = {
"default": dj_database_url.config(
env='DATABASE_URL',
conn_max_age=600,
conn_health_checks=True,
ssl_require=True,
),
}
Metadata
Metadata
Assignees
Labels
No labels