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


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:

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


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