gpt4 book ai didi

django检查模板中的当前URL是否包含特定单词

转载 作者:行者123 更新时间:2023-12-01 23:02:51 24 4
gpt4 key购买 nike

与此问题类似:

Django template, if tag based on current URL value

我只想检查网址中是否有单词-您知道,就像

if a.find(b) == -1

我怎样才能做到这一点?

最佳答案

Perhaps the in operator?

{% if b in request.path %}
hello world!
{% endif %}

如果那不能满足您的需求,则将逻辑移至 View 或创建一个 custom template tag.

关于django检查模板中的当前URL是否包含特定单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12877491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com