1

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

the databases settings seem to be in a different location noted in the manage.py file - which I have access to and has a password in the file. If the password was wrong in here would that not affect the ability of the live site to save to the database (which it can do) - I can log in as a basic front-end user and make changes to the projects associated with the user. Is it possible to verify if the password is correct?
if i understand correctly: Your manage.py file use different setting.py file than project?
my manage.py file has the line if name == "main": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hci.settings.demo") which has the demo.py file with the database settings... this file also calls a base.py file in the same folder with empty database settings I believe with the line from .base import * at the top of demo.py does this makes any sense?
added response to main question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.