In Uncategorized

https://pypi.org/project/dj-database-url/

We configure our django project to in settings.py. This can be done by connectng directly to the DATABASE_URL in heroku like so:

       db_from_env = dj_database_url.config(conn_max_age=500)

This will connect us to whatever data base we have in this config varable.

Then make sure to provide a “default”

        DATABASES[‘default’].update(db_from_env)

If you dont want to use the DATABASE_URL config varible you can manually provide a database url like so:

DATABASES[‘default’] = dj_database_url.parse(‘postgres://ivanov:M8…’, conn_max_age=600)

The conn_max_age attribute is the lifetime of a database connection in seconds and is available in Django 1.6+. If you do not set a value, it will default to 0 which is Django’s historical behavior of using a new database connection on each request. Use None for unlimited persistent connections

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.