Yeah that’s the way I got around to fixing it, thanks for the help! On Thu, May 10, 2018 at 4:30 PM Christie, Marcus Aaron <[email protected]> wrote:
> Davis, > > Are you still having trouble with this? My best guess is that it might be > the order of the operands. > > now - datetime.timedelta(days=1) <= self.pub_date > > might not work since, I think, what happens here is the left hand side is > evaluated to a datetime instance and then __le__ is called on that instance > and passed the self.pub_date which is a Django DateTimeField instance. > However, the datetime instance’s __le__ method doesn’t know what to do with > a DateTimeField instance. However, if you reverse the order I think it will > work, at least that is the way they have it in the tutorial, because > DateTimeField.__le__ probably knows how to handle a datetime instance. > That is, I think the following would work: > > self.pub_date >= now - datetime.timedelta(days=1) > > > Marcus > > On May 9, 2018, at 9:42 AM, Davis Joseph <[email protected]> wrote: > > <image.png> > > I'm working through the Django tutorial ( > https://docs.djangoproject.com/en/2.0/intro/tutorial02/) > and I'm stuck on the error which is in line 15, the error being "Expected > type 'timedelta', got 'DateTimeField' instead error". How should I got > about fixing this? > >
