I saved a Microsoft Word document as an HTML document. I then copied and pasted the generated HTML into a Django template “document.html”.
I then mapped a URL to a simple view that loads this template.
def viewDocument(request):
return render_to_response('document.html')
Afterwards, I get this error when access the page for that view.
UnicodeDecodeError at /viewDocument/
'utf8' codec can't decode byte 0xd2 in position 67600: invalid continuation byte
Strangely, the HTML in document.html displays fine when I open the page generated from Microsoft Word in Google Chrome on my laptop. How come it doesn’t work as a Django template?
Because the file isn’t encoded in UTF-8.