Saturday, October 31, 2020

Re: Newbie looking for some help with Postgres <> Django connection

It's been a while since I used heroku, but iirc it just uses a formatted pg url.

Install the module dj-database-url and use this in settings instead of the default DATABASES layout, something like:

    'default': dj_database_url.config(os.environ['DATABASE_URL'], conn_max_age=1800)

Then set DATABASE_URL in the heroku (and your development) environment. This setting will be of the form:


Again, its been a while but I also seem to recall that the DATABASE_URL is provided to your app automagically(?) a part of the provisioning so does not need to be explicitly set there.  Using the dj_database_url module in your settings above is the key.

No comments:

Post a Comment