Search code examples
python-3.xdjangounicode

(unicode error) 'utf-8' codec can't decode byte 0xf3


I'm using Django 5.0.8 and Python 3.11, so in my view I use this:

context = RequestContext(request,
                {
                    'title':'sómething',
                    'formLogin': formLogin
                })

As you can see, I pass a string with 'ó' value. When I try to run my project, it gives me the error '(unicode error) 'utf-8' codec can't decode byte 0xf3'

This happens with any special characters, for what I know using '# -- coding: utf-8 --' at first, in my view, solve this, but not now. What can I do?


Solution

  • You need to save your file enconded with UTF-8 codec.