Reputation: 167
is there a way to pass in a variable in a tag in django templating?
For example, <a href="{% url '{{ url_path }}' %}">Click here</a>
, as you can see, I want to pass the url_path variable into the url tag, but when I do this, django treats {{ url_path }}
as the string itself, not the variable url_path. Is there a way to pass in that variable in the url tag? Thanks in advance!
Upvotes: 1
Views: 51
Reputation: 65
Don't use quotes, by using quotes Django thinks you want to pass the template page directly.
Upvotes: 0
Reputation: 476614
You simply pass a variable without using quotes, and without using curly brackets ({{ … }}
):
<a href="{% url url_path %}">Click here</a>
Upvotes: 1