views:

39

answers:

1

How can I check from within a Django template whether a given date is in the future?

Something like:

{% if event.date > now %}
+3  A: 

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 %}
gruszczy
+1. Register this function as a custom filter and you'll be all set.
Manoj Govindan