Opened 6 years ago

Closed 6 years ago

#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 %}

Change History (2)

comment:1 Changed 6 years ago by Aymeric Augustin

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

comment:2 Changed 6 years ago by Aymeric Augustin

Resolution: invalid
Status: newclosed

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.

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