[Solved]-Python error AttributeError: 'str' object has no attribute 'setdefault'

27👍

Each element in the DATABASES dict must itself be a dict. You have overwritten the ‘default’ entry to just be a string.

Since you are using sqlite3 and the default database name, you should just revert to the original version of the setting:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

0👍

It’s better if you show us your settings.py to check if it is ok.

Remember to use python3 instead of python. Sometimes I got strange errors for this reason.

python3 manage.py runserver 8080

Leave a comment