#8214 closed (fixed)
Filtering a date/time field omits results.
Reported by: | redwyrm | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | aug22sprint | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If the pub_date of an poll is today, then it ought to show up when I click Today or This month, but it isn't. It only shows up when I click Any date, Past 7 days, or This year.
My Poll model:
class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') #...
And my PollAdmin model:
class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}), ] inlines = [ChoiceInline] list_display = ('question', 'pub_date', 'was_published_today') list_filter = ['pub_date'] admin.site.register(Poll, PollAdmin)
Current date is August 10th, 2008...
Screenshot when filtering by "Any date": http://i38.tinypic.com/ayzdf.jpg
Screenshot when filtering by "Today": http://i33.tinypic.com/2342ut.png
My database backend is SQLite3.
Attachments (1)
Change History (9)
comment:1 by , 16 years ago
milestone: | → 1.0 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
by , 16 years ago
Attachment: | ticket_8214_fix_type_of_datetime_extract.patch added |
---|
_sqlite_extract returns unicode (not integer) in all cases, fixes failing compare
comment:4 by , 16 years ago
Has patch: | set |
---|---|
Keywords: | aug22sprint added |
Needs tests: | set |
comment:5 by , 16 years ago
Found that _sqlite_extract (see patch) was returning an integer for month, causing the filter to fail. This was introduced in ChangeSet 8131, which removed str() around the return value. We added unicode(). No one involved is a regular maintainer, so this needs review.
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
When you pass unicode strings to filter(dateyear=x) you end up with 0 results, made a quick hack to filter that iterated through and int()ed the unicode strings and everything works as expected.
Adventuring off to dig further...