[Django] #21087: "datatime" objects can not be JSON-serialized to be held in sessions

3 views
Skip to first unread message

Django

unread,
Sep 11, 2013, 4:57:00 AM9/11/13
to django-...@googlegroups.com
#21087: "datatime" objects can not be JSON-serialized to be held in sessions
--------------------------------------+--------------------
Reporter: epandurski@… | Owner: nobody
Type: Bug | Status: new
Component: Core (Serialization) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
I am using Django 1.6 beta 3.

In my view I try:
{{{
now = datetime.datetime.now(pytz.utc)
request.session['lstts'] = now
}}}
But I get the following error: http://dpaste.com/hold/1375033/

I presume the reason is the new serializer for session objects. I also
presume that "datatime" objects must be supported, because they are quite
useful and used.

--
Ticket URL: <https://code.djangoproject.com/ticket/21087>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 11, 2013, 5:04:11 AM9/11/13
to django-...@googlegroups.com
#21087: "datatime" objects can not be JSON-serialized to be held in sessions
-------------------------------------+-------------------------------------

Reporter: epandurski@… | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: master
(Serialization) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

The JSON format doesn't provide a type for dates/datetimes. We'll have to
resort to a hack to support this use case.

--
Ticket URL: <https://code.djangoproject.com/ticket/21087#comment:1>

Django

unread,
Sep 11, 2013, 6:48:48 AM9/11/13
to django-...@googlegroups.com
#21087: "datatime" objects can not be JSON-serialized to be held in sessions
-------------------------------------+-------------------------------------
Reporter: epandurski@… | Owner: nobody
Type: Bug | Status: closed
Component: Core | Version: master
(Serialization) | Resolution: fixed

Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => fixed


Comment:

This was discussed quite a bit during the implementation, and the caveats
of JSON serialization have been documented:

https://docs.djangoproject.com/en/dev/releases/1.6/#default-session-
serialization-switched-to-json

https://docs.djangoproject.com/en/dev/topics/http/sessions/#session-
serialization

You can continue to use the `PickleSerializer` if needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21087#comment:2>

Django

unread,
Sep 11, 2013, 6:49:08 AM9/11/13
to django-...@googlegroups.com
#21087: "datatime" objects can not be JSON-serialized to be held in sessions
-------------------------------------+-------------------------------------
Reporter: epandurski@… | Owner: nobody

Type: Bug | Status: closed
Component: Core | Version: master
(Serialization) | Resolution: wontfix

Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* resolution: fixed => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/21087#comment:3>

Reply all
Reply to author
Forward
0 new messages