I have just started learning Django after I took some tutorials for Python.
I am trying to connect my POSTGRES database to the Django project I have just created.
However, I am experiencing this problem:
django.db.utils.OperationalError: FATAL: database "producthuntdb" does not exist
I followed these steps:
1) Opened postgress by clicking its icon
2) Clicked on the database "postgress". The terminal opened and I wrote: CREATE DATABASE producthuntdb; The database has been created because I see it if I open postgress via its icon.
3) Went to my Django project in "settings" and change the SQLITE database to the following:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'producthuntdb',
'USER': 'mymac2017',
'PASSWORD': 'mypassword',
'HOST': 'localhost',
'PORT': '5432',
}
}
4) Run the code python3 manage.py migrate
However, I am getting the error:
django.db.utils.OperationalError: FATAL: database "producthuntdb" does not exist
So I did the following:
Cliking on postgress icon and opening the the database
producthuntdbOnce the terminal is open, I wrote:
\duThere are two users with the attributes:
1) mymac2017 | Superuser, Create role, Create DB | {}
2) postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
What am I doing wrong?
I tried to look other answers to this problem and most of the issues are from misspelling the database name OR not creating it. However, the name of my database is correct and I can see the database producthuntdb if I open postgres.
Many thanks for your help.
access deniederror?