Django打开测试网页时报错: 'utf-8' codec can't decode…… invalid start byte
所有项目文件和路径都无中文,计算机名为英文。
pyhon版本3.7.6, Django版本2.1
求问这种问题该怎么解决?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是你的html里面有不能解析的字符,到html文档里修改 utf-8 改成gbk 就好了
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />