我正在尝试使用 ElasticBeanstalk 安装 Django 应用程序。它失败了,异常是 settings.DATABASES is improperly configured. Please supply the ENGINE value
完整错误:
Command failed on instance. Return code: 1 Output: (TRUNCATED)... in
complain raise ImproperlyConfigured("settings.DATABASES is improperly
configured. " django.core.exceptions.ImproperlyConfigured:
settings.DATABASES is improperly configured. Please supply the ENGINE value.
Check settings documentation for more details.
container_command 01_migrate in .ebextensions/15_my.config failed. For more
detail, check /var/log/eb-activity.log using console or EB CLI.`
我在执行其中一个命令时遇到此错误:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput"
leader_only: True
这是我的 config/settings/production.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ebdb',
'USER': 'djangousername',
'PASSWORD': 'djangopassword',
'HOST': env('RDS_HOSTNAME'),
'PORT': '5432'
}
}
我有点确定 EB 仅从该文件而不是任何其他文件中选择配置,因为如果我更改该文件中的某些内容,它会在 ElasticBeanstalk env 创建时反射(reflect)出来。我还在我的整个应用程序中搜索了 DATABASES
仅在该文件中提及,即 <app-rot>/config/settings/production.py
或 <app-root>/config/settings/local.py
.在这两个地方,我都提供了 ENGINE
值同上。
如果我需要添加任何其他相关信息,请告诉我
最佳答案
这让我花了很长时间才弄清楚(就像 Django 和 EB 的大多数事情一样)。我认为您在控制台中设置的环境变量优先于您在其他任何地方设置的变量或设置,例如.ebextensions.
在我的例子中,错误是因为我的设置文件在我的 ebextensions 中设置正确,但在控制台变量中设置不正确。感谢@daniel 的提示
关于python - ElasticBeanstalk Django : Please supply ENGINE value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44090071/