Reputation: 195
I'm using Django and ajax to print data to an HTML table with jQuery and JSON.
It was working until new data came and had "ú@ñ"
type of characters and I got:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf9 in position 4: invalid start byte
I've read and tried many different possible reasons and it's still not working.
I've tried:
# -*- encoding: utf-8 -*-
at the beginning of my views.pyI'd rather avoid using .decode() for every string in my data but if there's no other solution, it's what I'll have to do.
Upvotes: 0
Views: 2539
Reputation: 631
Is changing only encoding of the source file, meaning you can define variables/comments using non-ascii chars.
You can try to use
json.dumps(..., ensure_ascii=False, encoding="ISO-8859-1")
Upvotes: 1