That’s what dj_database_url does — sets the engine, etc based on your environment variables.

I haven’t personally developed a Django app like this (sqlite + postgres) in years, since I first published the post. You may no longer need the sslmode workaround and can remove it entirely.

Another option is to create two versions of your settings.py — one for local development and another for production — where you set the databases explicitly.

Something like this: https://stackoverflow.com/a/15325966 is pretty common in the apps I’ve worked on.

Top writer in Technology | Backend Web Developer | bennettgarner.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store