Here's a specific example of what you can't do, because '\xd9' is not
valid unicode:
{{{
>>> from django.contrib.sessions.backends.db import SessionStore
>>> s = SessionStore()
>>> s['foo'] = '\xd9'
>>> s.save()
......
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd9 in position 0:
unexpected end of data
}}}
I'm considering this a documentation bug, as according to my research
there is no way to encode this non-utf8 data into JSON.
--
Ticket URL: <https://code.djangoproject.com/ticket/26831>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
A workaround could be to base64 encode, then decode at read, but still,
arbitrary raw bytes aren't JSON transmittable as is (AFAIK).
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:1>
* owner: nobody => sadaf2605
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:2>
* needs_docs: 1 => 0
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/6874 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318" 1f82b85]:
{{{
#!CommitTicketReference repository=""
revision="1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318"
Fixed #26831 -- Documented session data must be JSON encodable for
JSONSerializer.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"e6db7271547087034b1ee2db11676601706e67a3" e6db7271]:
{{{
#!CommitTicketReference repository=""
revision="e6db7271547087034b1ee2db11676601706e67a3"
[1.9.x] Fixed #26831 -- Documented session data must be JSON encodable for
JSONSerializer.
Backport of 1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:5>
Comment (by Tim Graham <timograham@…>):
In [changeset:"5d8332aaee77c8e598e93f67fa9061538d98b54f" 5d8332aa]:
{{{
#!CommitTicketReference repository=""
revision="5d8332aaee77c8e598e93f67fa9061538d98b54f"
[1.10.x] Fixed #26831 -- Documented session data must be JSON encodable
for JSONSerializer.
Backport of 1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:6>