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:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章