Opened 5 years ago

Closed 5 years ago

#17830 closed Bug (fixed)

DateFieldListFilter "Past 7 days" filter uses naive datetime when USE_TZ is set.

Reported by: Glenn Washburn <development@…> Owned by: Aymeric Augustin
Component: contrib.admin Version: 1.4-beta-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The "Past 7 days" link for the DateFieldListFilter always contains a serialized naive datetime. This becomes a problem when USE_TZ is set because that value with get parsed back into a naive datetime and used directly in a QuerySet.filter call. The warning about using a naive data time will be raised.

Attachments (1)

17830.diff (9.6 KB) - added by Aymeric Augustin 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by Aymeric Augustin

Owner: changed from nobody to Aymeric Augustin
Triage Stage: UnreviewedAccepted

comment:2 Changed 5 years ago by Aymeric Augustin

Severity: NormalRelease blocker

Changed 5 years ago by Aymeric Augustin

Attachment: 17830.diff added

comment:3 Changed 5 years ago by Aymeric Augustin

Has patch: set

To fix this problem, I had to modify DateFieldListFilter to avoid the __year, __month and __day lookups -- because of #17260, these don't work well when time zone support is enabled.

comment:4 Changed 5 years ago by Jannis Leidel

Triage Stage: AcceptedReady for checkin

comment:5 Changed 5 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

In [17670]:

Fixed #17830 -- Modified list_filter on DateTimeFields to account for the new time zone support. Thanks Glenn Washburn for the report and Jannis Leidel for the review.

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