0

im trying to solve a problem related to this eror message i get when i call a function in Django shell.

The error i get in Django shell is TypeError: can't compare datetime.datetime to datetime.date. But when i look at the code variables status and created are date objects still in django shell its interperted as a datetime filed.

 In [91]: print(one.recepie_status())
 ------------------------------------------------------ 
 ---------------------
 TypeError                                 Traceback 
 (most recent call last)
 <ipython-input-91-47aeca6a3105> in <module>
 ----> 1 print(one.recepie_status())

 E:\Projekt\Fooders\fooders\recepies\models.py in 
 recepie_status(self)
 18         status=(date.today()-timedelta(days=15))
 19         created = datetime.date(self.created_at)
---> 20     if created > status:
 21             return "New"
 22         else:

 TypeError: can't compare datetime.datetime to datetime.date
The
  • 73
  • 7

0 Answers0