0

I don't really know how to describe what I'm aiming at (EDIT: I want a dynamic attribute lookup), but I'm trying to do something like this <p>{{dict.{{object.field}}}}</p> in a template. I also tried:

{% with object.field as field %}
     {{dict.field}}
{% endwith %}

which didn't work either. Do you know how to tackle this properly?

Jason Aller
  • 3,475
  • 28
  • 40
  • 37
jnns
  • 4,450
  • 4
  • 37
  • 70

2 Answers2

1

See this SO question.

Community
  • 1
  • 1
Cat Plus Plus
  • 119,938
  • 26
  • 191
  • 218
0

To loop through a dictionary you use "for":

{% for dictionary.object as obj %}
    {{ obj.field }}
{% endfor %}
markmywords
  • 693
  • 5
  • 13