JavaScript
x
25
25
1
{% for stg in statusUrl %}
2
<tr>
3
<td>{{forloop.counter}}</td>
4
<td>{{stg.title}}</td>
5
<td>
6
<a href="{% url {{stg.addLink}} %}" class="btn text-secondary px-0">
7
<i class="fas fa-plus"></i></a>
8
</a>
9
10
11
<a href="{% url {{stg.editLink}} invoice.id %}" class="btn text-secondary px-0">
12
<i class="fa fa-edit fa-lg"></i>
13
</a>
14
15
<a href="{% url {{stg.deleteLink}} invoice.id %}" class="btn text-secondary px-0">
16
<i class="far fa-trash-alt fa-lg text-danger float-right"></i>
17
</a>
18
19
<a href="{% url {{stg.previewLink}} invoice.id %}" class="btn text-secondary px-0">
20
<i class="fas fa-file-invoice"></i>
21
</a>
22
</td>
23
</tr>
24
{% endfor %}
25
Trying to pass urls.py view
names dynamically to template and then creating hyperlink to each view. How can href
be adjusted to handle it.
Advertisement
Answer
I do not know what stg.addLink returns but to make it work you need to change
from
JavaScript
1
3
1
"{% url {{stg.editLink}} invoice.id %}"
2
3
to
JavaScript
1
3
1
"{% url stg.editLink invoice.id %}"
2
3
BUT AGAIN it may not work. It depents what stg.editLink returns