#183 closed defect (fixed)
TypeError: can't compare datetime.datetime to datetime.date
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Template system | Version: | |
Severity: | normal | Keywords: | |
Cc: | moof@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Error:
There's been an error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 63, in get_response return callback(request, **param_dict) File "/usr/lib/python2.4/site-packages/django/views/generic/date_based.py", line 108, in archive_month if date >= now: TypeError: can't compare datetime.datetime to datetime.date
Change History (3)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Cc: | added |
---|
comment:3 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The same problem exists in archive_day(). Furthermore, there's a logic bug in the "is the month in the past?" check in archive_month(). It checks whether date >= now -- but date is constructed from passing just a year and month to time.strptime, which always fills in "1" for the day if the day is missing. Therefore, if today is July 25th, 2005, date will be 2005-07-01 and now will be 2005-07-25, so the check will return False. But we wanted it to return True in this scenario, because the month being examined does contain today and so we do want to add "<= (now)" to the SQL clause. Therefore, the check should really be "if last_day >= now".
The following patch will fix all three of these bugs: