#10458 closed (fixed)
next_month and previous_month in views.generic.date_based.archive_month return wrong dates
Reported by: | alasdair | Owned by: | fperetti |
---|---|---|---|
Component: | Generic views | Version: | 1.0 |
Severity: | Keywords: | next_month previous_month, pycamp2009 | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
next_month and previous_month return different days than the documentation says. This isn't a huge problem, since it is probably the month that is required.
The documentation says that django.views.generic.date_based.archive_month should return:
"next_month: A datetime.date object representing the first day of the next month ..."
However it returns a datetime.date object representing the second day of the next month. This is because on lines 146 and 148, a timedelta is added to last_month, which is already set to the required first date.
Similarly, the documentation says:
"previous_month: A datetime.date object representing the first day of the previous month ..."
when it actually returns the last day of the previous month.
This is my first django bug report, apologies if I've done it in the wrong way.
Attachments (1)
Change History (12)
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Owner: | changed from | to
---|
comment:3 by , 16 years ago
Keywords: | pycamp2009 added |
---|
by , 16 years ago
Attachment: | patch.diff added |
---|
comment:4 by , 16 years ago
without the patch:
fede@Zoka:~/Desktop/django/tests$ ~/django_test/sqlite3 views ====================================================================== FAIL: Regression for #3031: Archives around Feburary include only one month ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/fede/Desktop/django/tests/regressiontests/views/tests/generic/date_based.py", line 77, in test_archive_month_includes_only_month self.assertEqual(response.context['next_month'],date(2004, 3, 1)) AssertionError: datetime.date(2004, 3, 2) != datetime.date(2004, 3, 1) ---------------------------------------------------------------------- Ran 31 tests in 1.295s FAILED (failures=1)
with the patch:
fede@Zoka:~/Desktop/django/tests$ ~/django_test/sqlite3 views ---------------------------------------------------------------------- Ran 31 tests in 1.276s OK
comment:5 by , 16 years ago
Has patch: | set |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:7 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Since nothing's been checked into the source tree, this isn't fixed. Please read the contributing documentation to learn about ticket statuses.
comment:9 by , 16 years ago
#10688 reported the same next_month issue and provided a patch with another approach.
comment:10 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Add patch and test