{{{
return self.pub_date >= (timezone.now() -
datetime.timedelta(days=1)).timestamp()
}}}
... instead of ...
{{{
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
# PyCharm complains: "Expected type 'timedelta', got 'DateTimeField'
instead"
}}}
... will result in the correct type returned and PyCharm will not complain
anymore.
[https://django.readthedocs.io/en/stable/intro/tutorial02.html#playing-
with-the-api The related code example in the docs].
See also [https://stackoverflow.com/questions/61468142/pycharm-ide-
warning-on-django-doc-expected-type-timedelta-got-datetimefield this Stack
Overflow question].
--
Ticket URL: <https://code.djangoproject.com/ticket/34809>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.