如何在模板中比较request.path和user.username?

时间:2019-05-02 21:24:15

标签: python html django

我尝试过

{% if request.path == "/{{user.username}}" %}
                  You are in Contact</p>
  {% else %}
            nono

但这不起作用

1 个答案:

答案 0 :(得分:1)

如果失败,则输出一些有用的信息,以便您了解原因:

{% if request.path == "/{{ user.username }}" %}
    You are in Contact
{% else %}
    {{ request.path }} is not the same as /{{ user.username }}
{% endif %}