【问题标题】:How can I compare request.path and user.username in a template?如何比较模板中的 request.path 和 user.username?
【发布时间】:2019-09-21 10:44:58
【问题描述】:

我试过了

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

但它不起作用

【问题讨论】:

标签: python html django


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2012-05-03
    • 1970-01-01
    • 2013-03-04
    • 1970-01-01
    • 2021-08-25
    • 2011-04-17
    • 2023-03-29
    • 1970-01-01
    相关资源
    最近更新 更多