Heroku Postgres - 为什么我的生产数据库可以正常工作,即使 settings.py - Django 中没有列出?

Heroku Postgres - How come my production database is working, even though not listed in settings.py - Django?

我几个月前在 Heroku 中配置了我的数据库,所以不记得我采取的具体步骤。我正在使用 Heroku-Postgres 附加组件:https://devcenter.heroku.com/articles/heroku-postgresql

我有一个 DATABASE_PASS 在 Heroku 中被列为配置变量。我有一个 DATABASE_URL

的配置变量

在我的 settings.py 文件中,我只有以下与我的数据库相关的内容。如果 DATABASES 变量仅引用本地主机,为什么我的应用程序仍在 Heroku 上运行?

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'my_dev',
        'USER': 'postgres',
        'PASSWORD': os.environ.get('DATABASE_PASS'),
        'HOST': 'localhost',
        'PORT': '5410',
    }
}

Heroku-Postgres 文档说明如下:

The value of your app’s DATABASE_URL config var might change at any time. You should not rely on this value either inside or outside your Heroku app.

我是不是做错了什么?我不应该依赖 DATABASE_URL 作为配置变量吗?

其他详细信息 - 我正在使用 django-heroku pip 包。

Why is my app still working in production on Heroku if DATABASES variable is referring to localhost only?

Additional Detail - I am using the django-heroku pip package.

django-heroku 做了很多,包括从 DATABASE_URL 环境变量自动设置数据库:

This will automatically configure DATABASE_URL, ALLOWED_HOSTS, WhiteNoise (for static assets), Logging, and Heroku CI for your application.