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,541
  • 28
  • 38
  • 38
jnns
  • 5,148
  • 4
  • 47
  • 74

2 Answers2

1

See this SO question.

Community
  • 1
  • 1
Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
0

To loop through a dictionary you use "for":

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