Django打开测试网页时报错: 'utf-8' codec can't decode…… invalid start byte

发布于 2022-09-12 02:05:00 字数 3503 浏览 21 评论 0

所有项目文件和路径都无中文,计算机名为英文。
pyhon版本3.7.6, Django版本2.1
求问这种问题该怎么解决?

)%7PC(%Q_DVS$U7%W5EB(XH.png
E`~B{FGVRMF8I($AY0X$09L.png

Traceback完整内容:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 2.1
Python Version: 3.7.6
Installed Applications:
['pages.apps.PagesConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\core\handlers\exception.py" in inner
  34.             response = get_response(request)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\core\handlers\base.py" in _get_response
  156.                 response = self.process_exception_by_middleware(e, request)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\core\handlers\base.py" in _get_response
  154.                 response = response.render()

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\response.py" in render
  106.             self.content = self.rendered_content

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\response.py" in rendered_content
  81.         template = self.resolve_template(self.template_name)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\response.py" in resolve_template
  63.             return select_template(template, using=self.using)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\loader.py" in select_template
  42.                 return engine.get_template(template_name)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\backends\django.py" in get_template
  34.             return Template(self.engine.get_template(template_name), self)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\engine.py" in get_template
  144.         template, origin = self.find_template(template_name)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\engine.py" in find_template
  126.                 template = loader.get_template(name, skip=skip)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\loaders\base.py" in get_template
  24.                 contents = self.get_contents(origin)

File "C:\Users\13308\.virtualenvs\pages-tyRMmbey\lib\site-packages\django\template\loaders\filesystem.py" in get_contents
  24.                 return fp.read()

File "c:\users\13308\appdata\local\programs\python\python37\lib\codecs.py" in decode
  322.         (result, consumed) = self._buffer_decode(data, self.errors, final)

Exception Type: UnicodeDecodeError at /
Exception Value: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

靑春怀旧 2022-09-19 02:05:00

是你的html里面有不能解析的字符,到html文档里修改 utf-8 改成gbk 就好了
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文