【发布时间】:2012-10-04 08:33:32
【问题描述】:
类似于这个问题:
Django template, if tag based on current URL value
我只想检查网址中是否有单词 - 你知道,比如
if a.find(b) == -1
我该怎么做?
【问题讨论】:
-
downvoters - 关于这个问题的评论,也许?
标签: django
类似于这个问题:
Django template, if tag based on current URL value
我只想检查网址中是否有单词 - 你知道,比如
if a.find(b) == -1
我该怎么做?
【问题讨论】:
标签: django
{% if b in request.path %}
hello world!
{% endif %}
如果这不能满足您的需要,则将逻辑移至您的视图或创建custom template tag.
【讨论】:
忘记request参数并使用:
{% if 'search_term' in request.GET %}
Hello World!
{% endif %}
【讨论】: