Reputation: 2078
I try to make a list from a dictionary, where I also have the name of a view stored (values.1
). So with every hit of the for loop I can link to the right page. Problem is, I can't figure out how I should fix the {{ url "view_name" }}
.
My template:
<table>
<tr>
<th colspan="2">Timers</th>
</tr>
{% for key, values in timers.items %}
<tr>
<td>{{ key }}</td>
<td><a href="{{ url values.1 }}">{{ values.0 }}</a></td>
</tr>
{% endfor %}
</table>
How can I change the url so it directs to value.1
?
Sample of timers: (keep in mind that views names are now still pretty much the same but they wont be on other occasions)
OrderedDict([('short job', ['Now', 'short_job']), ('medium job', ['Now', 'medium_job']), ('long job', ['Now', 'long_job']), ('booze', ['Now', 'booze']), ('drugs', ['Now', 'drugs']), ('heist', ['Now', 'heist']), ('bullet deal', ['Now', 'bullet_deal'])])
Upvotes: 1
Views: 1368
Reputation: 11290
url
is a template tag and not a variable, so changing:
{{ url values.1 }}
into:
{% url values.1 %}
should do the trick.
Upvotes: 3