I have a problem comparing dates in Django. I followed the hint How to compare dates in Django but it does not work. Maybe you can help me.
My code:
modelys.py
class Customer(models.Model):
last_updated = models.DateTimeField(auto_now_add=True)
views.py
@property
def is_past_due(self):
return (date.today() - self.date)> timedelta(1)
home.html
{% if customer.last_updated.is_past_due %}
<td class="table-danger">{{ customer.last_updated }}</td>
{% else %}
<td class="align-middle">{{ customer.last_updated }}</td>
{% endif %}
I am using Bootstrap, so when the difference between two dates has a more than one day I want a tablefield to become 'danger'-ous ;-), but nothing changes.
Thanks in advance.
PS: edited the typo in def timdedelta to timedelta.