I would like to know how I can pass url as parameter of an include in django template.
I have in my code, a HTML file that is used to create a button. So when want to add this button I just include it. Problem is that 1 of the parameters is URL, and for now I have not found other solution than putting text url.
SO what I have this:
{% include "button.html" with title="title" link="/new-event/" %}
and I would have to have something like:
{% include "button.html" with title="title" link={% url myview.view%} %}
Thank you very much!
I believe you would have to assign the url to a variable that is added to the context in order to use it in an include tag.
Example:
view:
template:
If it’s a value you need in every template, you might consider adding a context processor to add the reversed url value to the context