与此问题类似:
Django template, if tag based on current URL value
只有我想检查网址中是否有单词 - 你知道,比如
if a.find(b) == -1
我该怎么做?
答案 0 :(得分:9)
{% if b in request.path %}
hello world!
{% endif %}
如果这不能满足您的需求,请将逻辑移至您的视图或创建custom template tag.
答案 1 :(得分:0)
忘记request
参数并使用:
{% if 'search_term' in request.GET %}
Hello World!
{% endif %}