我可以通过以下方式获取当前页面标题的输出:
{% block title %}{% endblock %}
但是,如何在有条件的情况下使用它呢?这似乎不起作用:
{% if title == "Bla" %}
doing some stuff!
{% endif %}
谢谢!
答案 0 :(得分:1)
Your current syntax is correct according to the Django docs,仔细检查title
是否具有您认为的值。
==
运营商
平等。示例:
{% if somevar == "x" %}
This appears if variable somevar equals the string "x"
{% endif %}