How to See if a String Contains Another String in Django Template

Try removing the extra {{...}} tags and the "..." quotes around request.build_absolute_uri, it worked for me.

Since you are already within an {% if %} tag, there is no need to surround request.build_absolute_uri with {{...}} tags.

{% if 'index.html' in request.build_absolute_uri %}
    hello
{% else %}
    bye
{% endif %}

Because of the quotes you are literally searching the string "{{ request.build_absolute_uri }}" and not the evaluated Django tag you intended.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)