模板中标题的条件?

时间:2013-02-20 00:45:18

标签: python django django-templates

我可以通过以下方式获取当前页面标题的输出:

{% block title %}{% endblock %}

但是,如何在有条件的情况下使用它呢?这似乎不起作用:

{% if title == "Bla" %}
   doing some stuff!
{% endif %}

谢谢!

1 个答案:

答案 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 %}