python - How to tell If Expression to return an empty string in Jinja2 -
i have input tag of date type value want set ''
if dictionary doesn't contain isodate. if dictionary contain isodate, formats isodate string displayed correctly:
<input type="date" value="{% '' if mydict['date']=='' else mydict['date'].strftime('%y-%m-%d')%}">
but error message:
templatesyntaxerror: tag name expected
i appreciate advice.
it should double curly braces {{ your_expression }}
<input type="date" value="{{ '' if dict['date']=='' else dict['date'].strftime('%y-%m-%d') }}">
Comments
Post a Comment