Opened 11 years ago

Closed 9 years ago

#22316 closed New feature (fixed)

TimeField lacks hour/minute filters

Reported by: Matthew Somerville Owned by: Matthew Somerville
Component: Database layer (models, ORM) Version: dev
Severity: Normal 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

#8424 added hour/minute/second filter lookups to DateTimeField, but not TimeField. I'm not sure if this was deliberate, but it would seem useful to have the functionality on TimeFields too if possible.

A workaround is to use a DateTimeField and hide/set the date part within the model.

Change History (12)

comment:1 by Simon Charette, 11 years ago

Triage Stage: UnreviewedAccepted
Version: 1.6master

From the discussion on #8424 it looks like those lookups were only added to DateTimeField to prevent possible clashes due to ORM limitations.

Now that the ORM lookup system has been overhauled (see #16187) it looks like django.db.lookups.DateLookup could be refactored to also account for TimeField.

comment:2 by Marc Tamlyn, 11 years ago

Owner: changed from nobody to Marc Tamlyn
Status: newassigned

comment:3 by Aymeric Augustin, 11 years ago

I added the lookups to DateTimeField despite the potential for clashes. I was working in the context of time zone support and simply didn't think about TimeField.

comment:4 by omer.drow@…, 11 years ago

Will this be implemented in 1.7?

comment:5 by Aymeric Augustin, 11 years ago

No, 1.7 is feature frozen.

comment:6 by Tim Graham, 9 years ago

Summary: TimeFIeld lacks hour/minute filtersTimeField lacks hour/minute filters

comment:7 by Matthew Somerville, 9 years ago

It looks like this was actually implemented for non-SQLite backends in 1.7 (I think as a side effect of #16187?), but on master it doesn't work in SQLite due to it having to use Python for date/time related functions. I have opened a PR that hopefully adds SQLite support for https://github.com/django/django/pull/4698

comment:8 by Tim Graham, 9 years ago

Has patch: set
Patch needs improvement: set

comment:9 by Matthew Somerville, 9 years ago

Owner: changed from Marc Tamlyn to Matthew Somerville

Will work on at DjangoCon EU sprint :)

comment:10 by Matthew Somerville, 9 years ago

Patch needs improvement: unset

comment:11 by Marc Tamlyn, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:12 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 2dc93bb:

Fixed #22316 -- Added time filters to TimeField on SQLite.

This was implemented for non-SQLite backends in 1.7 (as a
side effect of #16187).

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