Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

DJango pick Operating system username instead of user name present in settings file

About the issue

I created the project using command django-admin startproject test and updated the settings file to have mysql database details. Apart from that nothing added/updated/deleted in code.

Database details in config file

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        "Name": "django",
        "User": "root",
        "Password": "",
        "Host": "localhost",
        "Port": "3306"
    }
}

Then ran the command python manage.py runserver and gave me very strange error.

It says Access denied for user pankaj@localhost

Question

Settings file has username = root, why django pick operating system username

enter image description here

>Solution :

Django settings names must be all uppercase.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        "NAME": "django",
        "USER": "root",
        "PASSWORD": "",
        "HOST": "localhost",
        "PORT": "3306"
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading