Opened 17 years ago

Closed 17 years ago

#6888 closed (invalid)

archive_month generic view returns item from next month

Reported by: scottb Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords: archive_month, generic views
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I found the archive_month date based generic view can return objects from the next month. e.g. the view for objects in February will return objects for 1st March as well. It seems to be an issue when the model has a DateField, a DateTimeField set to a datetime.date, or a DateTimeField set to a datetime with time zero/midnight. Essentially any date on the first of the month where time is zero.

The archive_month view uses range e.g. 1st February to 1st March. This was done for ticket #992 long ago. If the object in March is a datetime with at least 1 second past midnight, it works fine. But when it's midnight (or a date instead of datetime), it falls in to the February range.

Attached is a patch to the regression tests to show what I mean. Also attached are a couple of possible fixes:

Fix 1: checks the year and month instead of using range.
Fix 2: uses gte and lt instead of range.

The same issue may affect the archive_week view. If I'm on the right track, I can write tests/patches for that.

Attachments (3)

month_tests.diff (4.1 KB ) - added by scottb 17 years ago.
Tests
fix_1_lte_gt.diff (1.0 KB ) - added by scottb 17 years ago.
fix_2_year_month.diff (1.0 KB ) - added by scottb 17 years ago.

Download all attachments as: .zip

Change History (5)

by scottb, 17 years ago

Attachment: month_tests.diff added

Tests

by scottb, 17 years ago

Attachment: fix_1_lte_gt.diff added

by scottb, 17 years ago

Attachment: fix_2_year_month.diff added

comment:1 by Ramiro Morales, 17 years ago

What database backend(s) are you using? which version? what exact revision of Django did you use for these tests?

comment:2 by Marc Fargas, 17 years ago

Resolution: invalid
Status: newclosed

From the bug description I can only read "your database server is screwed", as the reporter did not provide furter requested information I'm closing as invalid.

If you can provide the missing information to help us reproduce this bug, feel free to reopen this ticket (if it's a Django problem).

Thanks.

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