Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21487 closed Bug (fixed)

Incorrect documentation on using timezones and session in 1.6

Reported by: filipp Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords: session, timezone, json
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The 1.6 documentation on using Time zones (https://docs.djangoproject.com/en/1.6/topics/i18n/timezones/) says it's OK to do this:

request.session['django_timezone'] = pytz.timezone(request.POST['timezone'])

However that does not work since 1.6 with the default session serializer (serializers.JSONSerializer), resulting instead in a crash (TypeError), similar to this:

<DstTzInfo 'Europe/Stockholm' CET+1:00:00 STD> is not JSON serializable

Would be nice if the 1.6 documentation was be updated to say how this should be done since 1.6.

Change History (5)

comment:1 by Baptiste Mispelon, 11 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Yes, it should either be noted that the code only works with a non-default session serializer or better yet, fix the code so that it works with any session serializer.

comment:2 by Aymeric Augustin, 11 years ago

Just store the time zone name instead of the tzinfo object.

comment:3 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 1eddca0a5202993dbb3f437ccb74095f6647b825:

[1.6.x] Fixed #21487 -- Session cannot store tzinfo instances anymore.

Thanks filipp for the report.

comment:4 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 9f8810ac51afe7eda276ca54a46cb49fb23c1d5a:

Fixed #21487 -- Session cannot store tzinfo instances anymore.

Thanks filipp for the report.

Forward-port of 1eddca0a from stable/1.6.x.

comment:5 by filipp, 11 years ago

Thanks! :)

Note: See TracTickets for help on using tickets.
Back to Top