Introduction
Upon the attempt to create a migration script by running a certain command, it trigger an error message. Actually, it is appear on the title of this article. For the complete error message, it exist as follows :
(env) C:\programming\python\django\myproject>python manage.py makemigrations C:\app\python39\lib\site-packages\django\core\management\commands\makemigrations.py:105: RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': FATAL: password authentication failed for user "django_postgres" warnings.warn( No changes detected (env) C:\programming\python\django\myproject>
This article has a relation with the previous one. That article is an article with the title of ‘How to Present or Display a File using the HttpResponse Object in Django Application’ in this link. Furthermore, the described application in that article is becoming the reference which is triggering error in this article. The above command is actually a command which is an attempt to solve an error message appear in another article. The article is an article with the title of ‘How to Solve Error Message Programming Error relation does not exist on accessing Django Application’ in this link. So, before going on to the solution the following is the conditions of the application. First of all, the most important thing is the database configuration connection in the ‘settings.py’ file. It exist in the project folder. The following is the configuration lines :
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'USER': 'django_postgres', 'NAME': 'sysapp', 'PASSWORD': 'password', }
Solution
Actually, the solution is simple. Just try to access the PostgreSQL database server. Check whether the user account is available for connecting to the PostgreSQL database server. The following is an attempt for accessing it with the series of steps for solving the problem :
-
First of all, try to access the PostgreSQL database server using the database configuration connection exist in the ‘settings.py’ file :
C:\>psql -Udjango_postgres -d sysapp Password for user dafadf: psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "django_postgres" C:\>
-
Since the process for connecting to the database ends in a failure, just check the database for the account. Login to the PostgreSQL database server using any available admin account as follows :
C:\>psql -Upostgres Password for user postgres: psql (14.0) WARNING: Console code page (437) differs from Windows code page (1252) 8-bit characters might not work correctly. See psql reference page "Notes for Windows users" for details. Type "help" for help. postgres=#
-
Next, after successfully logging in. Just list any available users in the PostgreSQL database server by running the following command :
postgres=# \du+ List of roles Role name | Attributes | Member of | Description -----------------+------------------------------------------------------------+-----------+------------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} | postgres=#
-
Following after, apparently there only one user account available. In that case, just create a new user in the PostgreSQL which is used to connect from Django-based project or application. Read the article in this link with the title of ‘How to Create User in PostgreSQL Database Server’. Another one with the same content available in this link with the same title which is also ‘How to Create User in PostgreSQL Database Server’. But there are several main different exist in the syntax. It exist as follows with directly a real example :
postgres=# create user django_postgres with encrypted password 'password'; CREATE ROLE postgres=#
-
Don’t forget to assign the correct privileges to the new created user by executing the following command :
postgres=# grant all on database sysapp to django_postgres; GRANT postgres=#
-
Finally, just try to execute the command for running the migration generation script process Django-based internal service once more. If there are no further error appear, it will run normally.