Django - 网页加载报错:A server error occurred. Please contact the administrator

1.网页加载时报错显示:
Django - 网页加载报错:A server error occurred. Please contact the administrator_第1张图片
2.pycharm中Terminal报错显示:
如: File “E:\flask_env\django_env\lib\site-packages\django\views\debug.py”, line 332, in get_trace
back_html
t = DEBUG_ENGINE.from_string(fh.read())
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: illegal multibyte seque
nce
3.解决方法:
打开你上述报错文件位置:E:\flask_env\django_env\lib\site-packages\django\views\debug.py 文件,转到line331行:

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

就成功了。

你可能感兴趣的:(django)