I'm not sure what you are looking for, but you can compare datetime with datetime.now ().
I found that a datetime object can create a new datetime object:
In [1]: import datetime
In [2]: wasNow = datetime.datetime.now()
In [3]: wasNow
Out[3]: datetime.datetime(2017, 7, 28, 14, 17, 21, 889530)
In [4]: wasNow.now()
Out[4]: datetime.datetime(2017, 7, 28, 14, 17, 30, 105077)
and now that you have the date object in the jinja template, you can create a new datetime object from the existing one and compare it as:
{% if item.date < item.date.now() %}
<p> This will display if the item.date is before item.date.now(). </p>
{% endif %}
I hope this helps you try comparing dates using jinja.
source
share