[Fixed]-Django check within template if the current url has a particular word in it


Perhaps the in operator?

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

If that doesn’t accomplish what you need then move the logic to your view or create a custom template tag.


Forget request parameters and use:

{% if 'search_term' in request.GET %}
  Hello World!
{% endif %}

Leave a comment