【发布时间】:2018-10-08 23:32:48
【问题描述】:
如何进行不区分大小写的字符串比较?
就我而言,当 topic.title 等于 page.slug 时,我需要添加一个类 menu_active。但是,现在
- topic.title=主页
- page.slug = 主页
所以我的条件失败了
nav_bar.html
{% for topic in landing_pages %}
<li role="presentation">
<a class="{% if topic.title == page.slug %}menu_active{% endif %}" href="/{{topic.slug}}/">{{topic.title}}</a>
</li>
{% endfor %}
【问题讨论】:
标签: django django-templates wagtail