user2213980
user2213980

Reputation: 15

Can not create superuser for Django site - PostgreSQL database- fatal error: password authentication

I am an extreme newbie to Django and using shell. Hence please be gentle. I am working on a site where the owner has lost the relationship with the developer and hence passwords to the admin accounts (front-end and back-end). I am trying to create superusers for both but am having problems with the database. The site uses a PostgreSQL database. In the shell I activate the virtual environment and run my command:

python3 manage.py createsuperuser

The email address is requested and enter but receive the error after several lines of script.

django.db.utils.OperationalError: FATAL: password authentication failed for the user "xxx".

Do I need to somehow activate or enable the connection to the database before running the command?? Again really new and not trying to be the developer on the site- just trying to gain access and create users. Many thanks.

ADDITION BASED ON CONVERSATION BELOW

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'hci',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

except from base.py

from .base import *

DEBUG = True

TEMPLATES[0]['OPTIONS']['debug'] = True

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
     }
}

DATABASES['default'].update({
    'NAME': 'xxx_hcidemo',
    'USER': 'xxx_hcidemo',
    'PASSWORD': 'xxxxxxxxxx',
    'HOST': 'localhost',
})

BROKER_URL = 'redis://localhost:11201/0'
CELERY_RESULT_BACKEND = 'redis://localhost:11201/0'

entire demo.py file with password and username removed....

Solution was found! Many thx- the manage.py file was pointing at demo database - had to change to point at the production database. Completely agree - bad set-up but I now have access.

Upvotes: 1

Views: 2577

Answers (1)

Tomasz Jakub Rup
Tomasz Jakub Rup

Reputation: 10680

Probably You (or someone else) change password to database.

Look at Your DATABASES settings in Your settings.py file and update PASSWORD field.

EDIT:

Your manage.py use different database settings, than site. Remove if __name__ == '__main__': from manage.py file and try to add user.

BTW. It's very bad solution to differentiation prod env from dev env in this way.

Upvotes: 1

Related Questions