背景:django == 2.2
Traceback (most recent call last): File "D:\software\python3.6\lib\wsgiref\handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "D:\software\python3.6\lib\site-packages\django\contrib\staticfiles\handlers.py", line 65, in __call__ return self.application(environ, start_response) File "D:\software\python3.6\lib\site-packages\django\core\handlers\wsgi.py", line 141, in __call__ response = self.get_response(request) File "D:\software\python3.6\lib\site-packages\django\core\handlers\base.py", line 75, in get_response response = self._middleware_chain(request) File "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 36, in inner response = response_for_exception(request, exc) File "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception response = handle_uncaught_exception(request, get_resolver(get_URLconf()), sys.exc_info()) File "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "D:\software\python3.6\lib\site-packages\django\views\debug.py", line 94, in technical_500_response html = reporter.get_traceback_html() File "D:\software\python3.6\lib\site-packages\django\views\debug.py", line 332, in get_traceback_html t = DEBUG_ENGINE.from_string(fh.read()) UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
解决办法:
python3.6\Lib\site-packages\django\views\debug.py
原:
def get_traceback_html(self): """Return HTML version of debug 500 HTTP error page.""" with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh: t = DEBUG_ENGINE.from_string(fh.read()) c = Context(self.get_traceback_data(), use_l10n=False) return t.render(c)
更改为:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。