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 , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | 1.6 → master |
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 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:6 by , 9 years ago
Summary: | TimeFIeld lacks hour/minute filters → TimeField lacks hour/minute filters |
---|
comment:7 by , 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 , 9 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
comment:10 by , 9 years ago
Patch needs improvement: | unset |
---|
comment:11 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
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 forTimeField
.