Django template tag to show null date as "still open" -
i have following code in django template:
{{date_from|date:"y-m"}} - {{date_to|default_if_none:"still open"|date:"y-m"}}
i get:
- "2012-08 - "
- "2012-11 - 2012-08"
- .. rest of values correctly displayed.
i this:
- "2012-08 - still open"
- "2012-11 - 2012-08"
- .. rest of values correctly displayed.
do have suggestions? think not displayed because date object.
change order of filters. use default
instead of default_if_none
(date
filter return empty string non-date/datetime object)
>>> t = template('{{date_to|date:"y-m"|default:"still open"}}') >>> t.render(context({'date_to': none})) u'still open' >>> t.render(context({'date_to': datetime.datetime.now()})) u'2014-04'
Comments
Post a Comment