python - How to convert string to uppercase / lowercase in Jinja2? -
i trying convert upper case string in jinja template working on.
in template documentation, read:
upper(s) convert value uppercase.
so wrote code:
{% if student.departament == "academy" %} academy {% elif upper(student.department) != "maths department" %} maths department {% endif %}
but getting error:
undefinederror: 'upper' undefined
so, how convert string uppercase in jinja2?
filters used |filter
syntax:
{% elif student.department|upper != "maths department" %} maths department {% endif %}
or can use str.upper()
method:
{% elif student.department.upper() != "maths department" %} maths department {% endif %}
jinja syntax python-like, not actual python. :-)
Comments
Post a Comment