0

I have started a new project and app in Django 2.2.5 and I use Python 3.7.4 in Pycharm 2019.1.3

I run the django dev server from Pycharm terminal and everything works fine until I use some local signs in the html templates like: "í" after that I get UnicodeDecodeError:

'utf-8' codec can't decode byte 0xed in position 345: invalid continuation byte

In settings.py the Language code is set to local language:

LANGUAGE_CODE = 'sk'

I am lost as to what to do with this. I tried trans and autoescape, setting the encoding at the top of the html file ... but it didn't work. Any ideas?

Stefan
  • 828
  • 12
  • 24

1 Answers1

2

As similar SO question suggests - this error most probably indicates that file (django template) contains invalid utf-8 characters, more specifically - file most probably has latin-1 encoding.

Some symbols may look the same in utf-8 / latin-1 but be encoded differently (a very common struggle when editing file on Windows, or inputting into web page that expects only utf-8).

Suggestion is to configure PyCharm (and other editors you are using) to use UTF-8 encoding and re-save file with it, possibly editing wrong characters.

Oleg Russkin
  • 4,234
  • 1
  • 8
  • 20
  • Thanks for your response. But I already did that. This didn't change anything. – Stefan Jan 19 '20 at 21:47
  • Ok, let me correct myself .. yeah, you are right. Pycharm is kinda slow applying the settings ... but it's exactly this. Thanks. – Stefan Jan 19 '20 at 21:50