#19181 closed Uncategorized (invalid)

Document caveats about using DateQuerySet in templates when time zone support is enabled.

Reported by: wiliamsouza83@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: docs
Cc: wiliamsouza83@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Improve the the warning in adding a example that when time zone settings.USE_TZ support is enabled and your time zone settings.TIME_ZONE is settled to America / Sao Paulo wich is UTC - 3 in BRT and UTC - 2 in BRST and DateQuerySet return "Oct. 10, 2012, midnight" you will get "Oct. 9, 2012, 9, 00, 00". You should turn off local time when displaying DateQuerySet to avoid problems:

{% load tz %}
{% localtime off %}
{% for month in date_list %}

<p>{{ month }}</p>

{% endfor %}
{% endlocaltime %}

Attachments (0)

Change History (2)

comment:1 Changed 18 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I still plan to fix this at some point, see #17260.

comment:2 Changed 18 months ago by aaugustin

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

Actually, your example still won't display the correct data, because the aggregation was performed in UTC and not in local time in the database.

Generally speaking, I don't want to document workarounds, I want to fix this bug.

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.