django后台一保存就报错A server error occurred. Please contact the administrator.

后台数据一保存就报错,而且不告诉你为什么错。

我重建了一个项目,在cmd里运行,终于发现了错误的痕迹。


    Traceback (most recent call last):
  File "D:\python\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "D:\python\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "D:\python\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "D:\python\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:\python\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "D:\python\lib\site-packages\django\views\debug.py", line 94, in technical_500_response
    html = reporter.get_traceback_html()
  File "D:\python\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

又是编码问题。。
分析代码:主要是找到下面这个文档,然后找到332行的代码。

File “D:\python\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

改成这样:加一个编码方式。
在这里插入图片描述
再然后再打开django后台admin,这次保存,它终于刷出了错误来了
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值