I have a python list, iterated over to display a bullet point list on a web page. I want to make each entry in the list lower case, but still keep the original case for what get’s displayed.
I’m getting the following warning via Django below:
TemplateSyntaxError at / Invalid block tag on line 12: 'catEntry', expected 'empty' or 'endfor'. Did you forget to register or load this tag?
My html:
{% extends "cats/layout.html" %} {% block title %} cats {% endblock %} {% block body %} <h1>All cats</h1> <ul> {% for entry in entries %} {% newEntry= entry.lower() %} <li><a href = 'cats/{{newEntry}}.md' </a>{{ entry }}</li> {% endfor %} </ul> {% endblock %}
thanks
Advertisement
Answer
{% filter force_escape|lower %} This text will be HTML-escaped, and will appear in all lowercase. {% endfilter %}
ref: https://docs.djangoproject.com/en/3.2/ref/templates/builtins/