Opened 5 years ago

Closed 5 years ago

#17343 closed Bug (fixed)

The {% now %} template tag does not use time zones

Reported by: Tomek Paczkowski Owned by: Aymeric Augustin
Component: Template system Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no


Current django-trunk now tag uses instead of
I've made patch to fix that, but I'd really like to have some help with writing test.

Here's my fork over on github:

Attachments (1)

tz.diff (2.5 KB) - added by Tomek Paczkowski 5 years ago.
Consolidated diff

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by Tomek Paczkowski

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

To clarify the issue:

Dates that are coming from Django (when using USE_TZ = True) should be presented in users current time zone.

That means this should true (regardless of time zone used):

with timezone.override('Europe/Warsaw'):
    assert Template('{% now "H:i:s" %}').render(Context()) == timezone.localtime('%H:%M:%S')

Currently user is presented with date localized to default time zone.

Last edited 5 years ago by Tomek Paczkowski (previous) (diff)

comment:2 Changed 5 years ago by Aymeric Augustin

Easy pickings: set
Needs tests: set
Owner: changed from nobody to Aymeric Augustin
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Changed 5 years ago by Tomek Paczkowski

Attachment: tz.diff added

Consolidated diff

comment:4 Changed 5 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

In [17169]:

Fixed #17343 -- Changed the {% now %} tag to use the current time zone when time zone support is enabled. Thanks oinopion for the report.

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