I am trying to follow Django tutorial (Django 1.9, Python 2.7) to implement my polls project, but style.css did not take effect (neither the color nor the backgroud image). https://docs.djangoproject.com/en/1.9/intro/tutorial06/
When running the server, I observed the UnicodeDecodeError due to 'ascii' codec.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)
I followed the suggestion by set system default encoding to utf8, but when server was running it threw similar error due to 'utf8'.
How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte"
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte
So I think neither ascii nor utf8 is enough, and how can I fix it? I saw some posts provided some suggestion like json.loads, but I have no idea how to add in my Django project.
json.loads(unicode(opener.open(...), "ISO-8859-1")),
utf8' codec can't decode byte 0x89 in position 15: invalid start byte
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-6: invalid data
Issue Full Trace:
[17/Mar/2016 12:26:28] "GET /polls/ HTTP/1.1" 200 161
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 64, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 177, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 54, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 47, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line 40, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 66, in serve content_type, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 297, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 358, in init db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte