[英]Django; django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database
I'm a beginner and I've been creating a Django project.我是初学者,我一直在创建一个 Django 项目。 I'm trying to switch
sqlite3
db to postgresql
.我正在尝试将
sqlite3
db 切换到postgresql
。 But when I do make migrations
, this error occurred.但是当我做
make migrations
,发生了这个错误。
django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database
django.db.utils.OperationalError: 致命: 没有主机、用户、数据库的 pg_hba.conf 条目
I searched about this error.我搜索了这个错误。 And some people checked
pg_hba.conf
file, but I have no idea where this file is.有些人检查了
pg_hba.conf
文件,但我不知道这个文件在哪里。
Also when I created project before and did the same thing, there's no this error.此外,当我之前创建项目并做同样的事情时,没有这个错误。 Why is this error happening this time?
这次为什么会出现这个错误? What is the cause?
原因是什么?
How can I fix this error?我该如何解决这个错误?
Here is configuration part in settings.py
这是
settings.py
配置部分
DATABASES = {
'default': {
#elephantsql
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DATABASE_NAME', ''),
'USERS': os.environ.get('DATABASE_USER', ''),
'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
'HOST': os.environ.get('DATABASE_HOST', ''),
'PORT': os.environ.get('DATABASE_PORT'),
}
}
Looks like a typo to me :对我来说看起来像是一个错字:
'USERS': os.environ.get('DATABASE_USER', ''),
should probably be:应该是:
'USER': os.environ.get('DATABASE_USER', ''),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.