user2613717
user2613717

Reputation: 81

URL name in django template.if statement

How to add correctly in my example {% url 'myview' %}

{% if request.path == {% url 'myview' %} %}

?

Upvotes: 8

Views: 4734

Answers (1)

alecxe
alecxe

Reputation: 474161

Django has this nice built-in feature that you can assign the url to a variable and then use it:

{% url 'myview' as my_view %}
{% if request.path == my_view %}

Upvotes: 17

Related Questions