Code

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#17831 closed Bug (duplicate)

Admin's date list filter's "This month/year" and "Today" are incorrect when USE_TZ is set (with the postgres backend).

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

Description (last modified by julien)

This may be applicable to other backends, but I'm not sure.

When using USE_TZ the backend connection is set to use UTC. So __year/__month/__day lookup filters will filter where the UTC timestamp has a year/month/day of the lookup value. However, what's really desired is to use the timestamp at the current timezone. For example, the current code when filtering for "today" datetimes which are not in UTC can potentially return a list of matching records where the set of days being displayed is more than one.

Attachments (0)

Change History (4)

comment:1 Changed 2 years ago by julien

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker

I haven't been able to review this fully but this seems like a potential release blocker.

comment:2 Changed 2 years ago by akaariai

This is related to #17260, if not duplicate. Fixing this generally is going to be probably somewhat hard. I have one idea, though: you could manually add/subtract the offset from the datetime when doing the filtering. It is not perfect (DST not taken into account correctly). But it might be easy enough to do for 1.4.

comment:3 Changed 2 years ago by aaugustin

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

Indeed, this has the same root cause as #17260, which is a known limitation of the current implementation of time zone support.

Until now, #17260 didn't include "date_filter on a DateTimeField" in the list of problems; I've added it.

comment:4 Changed 2 years ago by aaugustin

In fact, the patch I prepared for #17830 fixes this too.

Add Comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.