zoukankan      html  css  js  c++  java
  • Django 2.2_错误:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence

      环境说明

      1.开发系统: windows

      2.IDE: pycharm  

      3.数据库: msyql,navicat

      4.编程语言: python3.7  (Windows x86-64 executable installer)

      5.虚拟环境: virtualenvwrapper

      6.开发框架: Django 2.2

    访问admin出现问题:

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence

    解决方法:

    1.直接点击下面这个错误提示,进入到debug.py文件,前在目录可能不一样(这是我项目虚拟环境的路径F:\CMCT\A01CMCT\study\Aenv\A02cabj).

    # 错误显示
    File "F:\CMCT\A01CMCT\study\Aenv\A02cabj\lib\site-packages\django\views\debug.py", line 332, in get_traceback_html 
    1 def get_traceback_html(self):
    2     """Return HTML version of debug 500 HTTP error page."""
    3     with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh:
    4         t = DEBUG_ENGINE.from_string(fh.read())
    5     c = Context(self.get_traceback_data(), use_l10n=False)
    6     return t.render(c) 

    2.在  open()  中加入  encoding = 'utf-8'  ===>  open(encoding = 'utf-8')  注意中间的引号,如果还报错就再重新输入一下两边的引号

    1 def get_traceback_html(self):
    2     """Return HTML version of debug 500 HTTP error page."""
    3     with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding = 'utf-8') as fh:
    4        t = DEBUG_ENGINE.from_string(fh.read())
    5     c = Context(self.get_traceback_data(), use_l10n=False)
    6     return t.render(c)

     3.重启项目再进入admin

  • 相关阅读:
    CSS盒子模型
    getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
    MYSQL中的CASE WHEN END AS
    单点登录的精华总结
    git&github
    June 21st 2017 Week 25th Wednesday
    June 20th 2017 Week 25th Tuesday
    June 19th 2017 Week 25th Monday
    June 18th 2017 Week 25th Sunday
    June 17th 2017 Week 24th Saturday
  • 原文地址:https://www.cnblogs.com/djtang/p/10194811.html
Copyright © 2011-2022 走看看