python - Do I need to install the PostgresSql in Project directory for it to work with psycopg2?
问题描述
I am trying to make migrations to my newly created PostgresSql database when I run
python manage.py makemigrations
it gives me the following error:
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: role "<MYNAME>" does not
exist
the here is my windows username
I think it is maybe because I have installed PostgresSQl in the C: directory. I had to use
psql --username=postgres
in CMD to get into the database and make new user with a superuser role.
Settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('POSTGRES_DB_NAME'),
'USER': os.environ.get('POSTGRES_DB_ADMIN'),
'PASSWORD': os.environ.get('POSTGRES_DB_PASS'),
'HOST': 'localhost',
'PORT': '5432'
}
}
Any help with this would be appreciated.
解决方案
推荐阅读
- python - Python 检查网络连接
- node.js - Nodejs Https服务器(将证书文件地址放在代码中是否安全)
- java - IntegrationFlow + 2 个条件转换器 + 出站网关
- elm - Elm 中的编译时不变性/属性检查
- javascript - 在 Electron 应用程序的 iframe 中找不到嵌入 PDF 的高度?ScrollHeight 的值错误
- swift - Swift:检查来自同一类的 2 个对象是否具有不同的值?
- javascript - 有没有办法在单击按钮时显示另一个表单,而不是仅在用户仅使用 JS 单击“是”后继续执行默认操作
- java - 通过java递归下载远程HTTP目录
- c# - Discord NET C# 角色列表
- android - 具有固定宽度android的recyclerview中的水平平滑滚动动画