Opened 5 months ago

Closed 5 months ago

Last modified 5 months 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


The 1.6 documentation on using Time zones ( 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.

Attachments (0)

Change History (5)

comment:1 Changed 5 months ago by bmispelon

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 5 months ago by aaugustin

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

comment:3 Changed 5 months ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 1eddca0a5202993dbb3f437ccb74095f6647b825:

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

Thanks filipp for the report.

comment:4 Changed 5 months ago by Aymeric Augustin <aymeric.augustin@…>

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 Changed 5 months ago by filipp

Thanks! :)

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.