You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airavata.apache.org by Davis Joseph <da...@iu.edu> on 2018/05/09 13:42:27 UTC
Expected type 'timedelta', got 'DateTimeField' instead error
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?
Re: Expected type 'timedelta', got 'DateTimeField' instead error
Posted by Davis Joseph <da...@iu.edu>.
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 <ma...@iu.edu>
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 <da...@iu.edu> 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?
>
>
Re: Expected type 'timedelta', got 'DateTimeField' instead error
Posted by "Christie, Marcus Aaron" <ma...@iu.edu>.
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 <da...@iu.edu>> 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?
Re: Expected type 'timedelta', got 'DateTimeField' instead error
Posted by "Pierce, Marlon" <ma...@iu.edu>.
Hi Davis, you may want to post this question to the Apache Airavata hipchat room: https://www.hipchat.com/g6Use7j8w.
Marlon
From: Davis Joseph <da...@iu.edu>
Reply-To: "dev@airavata.apache.org" <de...@airavata.apache.org>
Date: Wednesday, May 9, 2018 at 9:42 AM
To: "dev@airavata.apache.org" <de...@airavata.apache.org>
Subject: Expected type 'timedelta', got 'DateTimeField' instead error
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?