Django;django.db.utils.OperationalError:严重:主机,用户,数据库没有pg_hba.conf条目 [英] Django; django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database

查看:58
本文介绍了Django;django.db.utils.OperationalError:严重:主机,用户,数据库没有pg_hba.conf条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者,我一直在创建Django项目.我正在尝试将 sqlite3 db切换为 postgresql .但是当我进行迁移时,发生了此错误.

I'm a beginner and I've been creating a Django project. I'm trying to switch sqlite3 db to postgresql. But when I do make migrations, this error occurred.

django.db.utils.OperationalError:严重:主机,用户,数据库没有pg_hba.conf条目

django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database

我搜索了此错误.有些人检查了 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.

此外,当我之前创建项目并执行相同的操作时,没有此错误.为什么这次会发生此错误?是什么原因?

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?

如何解决此错误?

这是 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'),
    }
}

推荐答案

在我看来像错字了:
'USERS':os.environ.get('DATABASE_USER',''),
应该可能是:
'USER':os.environ.get('DATABASE_USER',''),

Looks like a typo to me :
'USERS': os.environ.get('DATABASE_USER', ''),
should probably be:
'USER': os.environ.get('DATABASE_USER', ''),

这篇关于Django;django.db.utils.OperationalError:严重:主机,用户,数据库没有pg_hba.conf条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆