I have one static dictionary
:
urls = {
'foo': 'http://example.com',
'bar': 'http://example2.com',
'test': 'http://example3.com'}
Then I have a list of tuples. Each tuple
contains one key of the previous dictionary:
myList = [('bar', 0.9),('test', 0.7),('foo', 0.5)]
I want to put in my template the related url for each key string in the descending order as they are in the list (created in this way obviously with the reverse = True
set).
In the template I have tried this, but, as expected, it doesn't work:
{% for i in myList %}
<tr>
<a href= " {{ urls[i[0]] }} ">
<td>
{{ i[0] }}
</td>
</a>
</tr>
{% endfor %}
So, how can I access the dictionary
elements?