Just wondering what the correct syntax is for checking if the current path is equal to some url:
{% if request.path == url "app_namespace:route_name" %}
Above doesn't work - but hoping someone knows a way or method for doing this lookup...
Just wondering what the correct syntax is for checking if the current path is equal to some url:
{% if request.path == url "app_namespace:route_name" %}
Above doesn't work - but hoping someone knows a way or method for doing this lookup...
You can use this syntax to save the url path in a template variable:
{% url 'app_namespace:route_name' as url_path %}
which you can later use within your if
condition
{% if request.path == url_path %}...{% endif %}
Note that you may also find this syntax useful when you need to use the output of a url
function within a blocktrans block:
{% blocktrans %}
<a href="{{ url_path }}">text to translate</a>
{% endblocktrans %}