title: Accessing a dict by variable in Django templates?
body: <p>My view code looks basically like this:</p>
  
  <pre><code>context = Context() 
  context['my_dict'] = {'a': 4, 'b': 8, 'c': 15, 'd': 16, 'e': 23, 'f': 42 }
  context['my_list'] = ['d', 'f', 'e', 'b', 'c', 'a']
  </code></pre>
  
  <p>And what I'd like to do in my Django template is this:</p>
  
  <pre><code>&lt;ul&gt;
  {% for item in my_list %} 
    &lt;li&gt;{{ item }} : {{ my_dict.item }}&lt;/li&gt;
  {% endfor %} 
  &lt;/ul&gt;
  </code></pre>
  
  <p>And I'd like this to output:</p>
  
  <pre><code>&lt;ul&gt; 
    &lt;li&gt; d : 16 &lt;/li&gt; 
    &lt;li&gt; f : 42 &lt;/li&gt; 
    &lt;li&gt; e : 23 &lt;/li&gt; 
    &lt;li&gt; b : 8 &lt;/li&gt; 
    &lt;li&gt; c : 15 &lt;/li&gt; 
    &lt;li&gt; a : 4 &lt;/li&gt; 
  &lt;/ul&gt; 
  </code></pre>
  
  <p>But the reference to the dict by variable name via <code>{{ my_dict.item }}</code> doesn't actually work.  I suspect it's internally doing <code>my_dict['item']</code> instead of <code>my_dict[item]</code>.  Is there any way to work around this?</p>