Django數據庫配置報錯object supporting the buffer API required

錯誤一:object supporting the buffer API required

在這裏插入圖片描述
需要將settings.py中mysql配置的密碼改爲字符穿:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',  # 數據庫引擎
        'NAME': '名稱',
        'HOST':'127.0.0.1',
        'PORT':3306,
        'USER':'root',
        #'PASSWORD':123456 # 之前寫法
        'PASSWORD':'123456'  # 修改爲字符串
        
    }
}

錯誤二:"AttributeError: ‘str’ object has no attribute ‘decod’

在這裏插入圖片描述
定位到報錯的地方:
在這裏插入圖片描述

錯誤三:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: illegal multibyte sequence

在這裏插入圖片描述
定位到332行將:

with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh:

改爲:

with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding='utf-8') as fh:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章