P.s. THIS PROBLEM WAS SOLVED (I WAS USING WRONG PORT NUMBER)
I am trying to configure Postgresql with django 2.2 on WINDOWS OS but ending up getting error. Here is what I did to configure postgres for my project:
- Installed postgresql latest version with all default configuration and gave my password
- Created database in SQL Shell (psql) by doing
CREATE USER nouman;
CREATE DATABASE blog OWNER nouman;
- Then I updated settings.py file for the database as:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'blog',
'USER': 'nouman',
'PASSWORD': 'my password',
'HOST': 'localhost',
'PORT': '',
}
}
- I installed psycopg2 by the command: "pip install psycopg2".
- But when I update the database by "python manage.py migrate" it gives this error:
Traceback (most recent call last):
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection
self.connect()
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\base\base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\postgresql\base.py", line 178, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\psycopg2\__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "nouman"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
-----------snip--------
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\psycopg2\__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "nouman"