I'm trying to use different stylesheet in django template if the time since publish is less than 15 minutes. I created the DateTimeField in my model that adds 15 minutes with time delta
blink = models.DateTimeField(default=datetime.datetime.now()+datetime.timedelta(minutes=15))
In the view.py I have defined dayandtime
dayandtime = datetime.datetime.now()
In the template I have this if
statement
{% if mi.blink > dayandtime %}
...
{% else %}
...
Unfortunately it goes to else even though the mi.blink
is greater than dayandtime
.
I tried to use answer from this question [question]: DateTime compare in django template
{% if mi.blink.date < dayandtime.date and mi.blink.time < dayandtime.time %}
but it's still not working. Is it because the timedelta has been added?