首页 > 解决方案 > 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.

标签: pythondjangowindowspostgresql

解决方案


推荐阅读