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

31👍

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.

1👍

Forget request parameters and use:

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

Leave a comment