Running into the same issue - charset isn't correct, I think it ought to be hardcoded to `utf-8`.
On Thursday, March 31, 2016 at 5:24:39 AM UTC-7, Tim Graham wrote: > > Looks reasonable, although I am not entirely clear what role charset has > in a JsonResponse. See https://code.djangoproject.com/ticket/23949. > > On Thursday, March 31, 2016 at 6:15:53 AM UTC-4, Daniel Blasco wrote: >> >> Hi, >> >> I'm testing the REST API of my application and I found an error that I >> think that's a Django's issue. >> >> I'm using: >> >> - Django==1.9.4 >> - djangorestframework==3.3.3 >> >> >> I have set the rest framework setting UNICODE_JSON to True. >> >> When i'm testing a JSON response that contains a special character like >> 'รก' then I get a UnicodeDecodeError. This is the traceback: >> >> Traceback (most recent call last): >> File ".../tests/assets/test_views.py", line 584, in test_get >> response.json() >> File ".../lib/python2.7/site-packages/django/utils/functional.py", line >> 13, in _curried >> return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs)) >> File ".../lib/python2.7/site-packages/django/test/client.py", line 662, >> in _parse_json >> return json.loads(response.content.decode(), **extra) >> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 268: >> ordinal not in range(128) >> >> >> If I change the line 662 in django/test/client.py to: >> >> return json.loads(response.content.decode(*response.charset*), **extra) >> >> then it works fine. In this case response.charset is utf-8. >> >> >> Thanks, >> Daniel >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cacd05db-9ab3-455b-b16f-52719b7337cd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

