Within a template, how do I access a dictionary value by specifying a key that is stored in a variable?
If I have a dictionary e.g.
eventEntriesDict
{1: 'A',
2: 'B',
3: 'C',
4: 'D',}
I can access any value from within the template by:
{{ eventEntriesDict.2 }}
This returns the expected value of B
What I would like to do however is
{% with myid = query.field.id %}
{{ eventEntriesDict.myid }}
{% endwith %}
If I try this I don’t get anything returned.
I’d be grateful for advice on where I’m going wrong.
Many thanks