[Answer]-UnicodeDecodeError when using django forms

1πŸ‘

I don’t have much experience with Django, but I have dealt with that exception a lot when working with Chinese text in Python. Usually you need to use decode() with a Chinese codec. I have found that β€˜gb18030’ works most frequently. So e.g., if you have a variable foo that holds Chinese strings, try foo.decode('gb18030')

πŸ‘€elethan

0πŸ‘

I know this is a bit old, but I was able to solve a similar error, using in top of forms.py the lines:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

A similar error was reported here:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)

πŸ‘€mseromenho

Leave a comment