python - Flask-Admin: UnicodeDecodeError: 'ascii' codec can't decode byte -
i'm trying build back-end interface application flask-admin. when try access form create new entry get:
unicodedecodeerror: 'ascii' codec can't decode byte 0xc3 in position 13: ordinal not in range(128)
going through stack trace, problem items in table contain non-ascii characters. how can solve issue? thanks!
in general, error solved forcing string array unicode unicode.encode()
method .
from python wiki page on subject
>>> u"a".encode("utf-8") 'a' >>> u"\u0411".encode("utf-8") '\xd0\x91' >>> "a".encode("utf-8") # unexpected argument type. 'a' >>> "\xd0\x91".encode("utf-8") # unexpected argument type. traceback (most recent call last): file "<stdin>", line 1, in <module> unicodedecodeerror: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
i suppose best solved modifying jinja macro responsible field formatting force values unicode.
Comments
Post a Comment