Using now in an if

52 views
Skip to first unread message

Larry Martell

unread,
Jun 25, 2012, 8:05:24 AM6/25/12
to django...@googlegroups.com
I'm trying to use now in an if like this:

{% if value|date:"Ymd" == now "Ymd" %}

This is failing with: 'Unused '"Ymd"' at end of if expression.'

If I quote it:

{% if value|date:"Ymd" == 'now "Ymd"' %}

I don't get the syntax error, but the if does not evaluate to true
when the dates match.

I need to see if the date in {{ value }} is `today' - how can I do that?

-larry

Daniel Roseman

unread,
Jun 25, 2012, 8:26:14 AM6/25/12
to django...@googlegroups.com
Write a custom "is_today" filter. Two lines of code.
--
DR.

Larry Martell

unread,
Jun 25, 2012, 10:27:42 AM6/25/12
to django...@googlegroups.com
Thanks for the reply. I ended up doing what I needed in python on the sever.

So I guess there is no way to use now in an if?
Reply all
Reply to author
Forward
0 new messages