How can I check from within a Django template whether a given date is in the future?
Something like:
{% if event.date > now %}
How can I check from within a Django template whether a given date is in the future?
Something like:
{% if event.date > now %}
Write a function on event named in_future
, that will compare event.date
with datetime.now()
and use it in the template. Don't put unnecessary logic into template.
Or as Manoj suggested, you can have a custom filter in_the_future
and call it:
{% if event.date|in_the_future %}