Nested Tag inside URL tag in Django Template
I have a list of items in my template which produce a table of hrefs. Now I want to send back the item.name to the appropirate view function based on the clicked item. The code should look something like this:
{% for item in myList %}
<li><a href="{% url myView arg="{{ item.name }}"%}"> {{ item.name }} </a> <li>
{% endfor %}
And the problem is the cre开发者_C百科ated nested tag and the {{ item.name }}
inside the view arg which doesn't work. Any ideas?
{% url myView item.name %}
should work, if the url pattern expects a positional argument! See the documentation of the url template tag!
精彩评论