[英]Django - settings.DATABASES is improperly configured. Please supply the ENGINE value
I've got a postgres DB which Django successfully connects to but when trying to create a new model I'm getting the error settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
我有一个 Django 成功连接到的 postgres 数据库,但是在尝试创建新的 model 时出现错误
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
I know settings.DATABASES is correctly configured as I've already created models which then Django used to create tables in the DB but for whatever reason it is now causing this error.我知道 settings.DATABASES 已正确配置,因为我已经创建了模型,然后 Django 用于在数据库中创建表,但无论出于何种原因,它现在都会导致此错误。 You can also see that I have already "supplied the ENGINE value".
您还可以看到我已经“提供了 ENGINE 值”。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['POSTGRES_DB'],
'USER': os.environ['POSTGRES_USER'],
'PASSWORD': os.environ['POSTGRES_PASSWORD'],
'HOST': 'db',
'POST': '5432',
}
}
All help is appreciated.感谢所有帮助。
Replace your ENGINE
setting by:将您的
ENGINE
设置替换为:
'ENGINE': 'django.db.backends.postgresql'
It is the correct setting in Django 3 and up.这是 Django 3 及更高版本中的正确设置。 See https://docs.djangoproject.com/en/3.0/internals/deprecation/#deprecation-removed-in-3-0 .
请参阅https://docs.djangoproject.com/en/3.0/internals/deprecation/#deprecation-removed-in-3-0 。
Turns out I'm an idiot.原来我是个白痴。
I'm using docker and I forgot that I need to enter the container to do DB migrations ♂️我正在使用 docker 忘记了我需要进入容器进行数据库迁移♂️
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.