I’m working moving a local Django app to Heroku so I can access from other computers. This is a personal project, which means I’ve been hacking a few things together to learn the systems.
I have been using SQLite3 locally (that was the default, I didn’t know any better). I’ve attached a Postgres database to the Heroku application.
With some initial tests, I’ve noticed that the Heroku version of the app is able to use the Postgres database, though I have made no changes to my settings.py
file. For example, this is what my database configuration looks like:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
I am surprised by this compatibility. How is the Heroku app able to connect to the Postgres database when I haven’t done any explicit configuration to make it work?
I assume there is something happening behind the scenes that overrides the SQLite3 database config in favor of the Postgres database.