Code

Opened 9 years ago

Closed 7 years ago

#137 closed defect (fixed)

TypeError: can't compare datetime.datetime to datetime.date in date_based.py

Reported by: nesh@… Owned by: jacob
Component: Generic views Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

R267:
When accessing /weblog/.... url, object_detail in date_based.py throws exception:

File "/Users/nesh/devel/workspace/django_src/django/views/generic/date_based.py", line 200, in object_detail
    if date >= now:

TypeError: can't compare datetime.datetime to datetime.date

Solution: (diff)

diff -u -r1.1 date_based.py
--- date_based.py	21 Jul 2005 12:24:11 -0000	1.1
+++ date_based.py	21 Jul 2005 12:40:45 -0000
@@ -188,7 +188,7 @@
             the object to be detailed
     """
     try:
-        date = datetime.date(*time.strptime(year+month+day, '%Y%b%d')[:3])
+        date = datetime.datetime(*time.strptime(year+month+day, '%Y%b%d')[:3])
     except ValueError:
         raise Http404
     mod = get_module(app_label, module_name)

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by mir@…

  • Component changed from Tools to Generic views
  • Owner changed from adrian to jacob
  • Triage Stage changed from Unreviewed to Accepted

I'm surprised to see this still applies.

comment:2 Changed 7 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

This was fixed two years ago today, in [308].

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.