title: Django template unable to access a dictionary lookup variable. What mistake am I doing in code?
body: <p>I'm learning django from djangobook.com</p>
  
  <p>As an exercise, I'm trying to print all <code>HttpRequest.META</code> dictionary in the form of a table using template.</p>
  
  <p><strong>views.py</strong> contains</p>
  
  <pre><code># Create your views here.
  from django.http import HttpResponse
  from django.shortcuts import render
  
  def http_headers(request):
      return render(request,'headers.html',{'headers':request.META})
  </code></pre>
  
  <p><strong>headers.html</strong> &lt;-- template</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;&lt;table border="1"&gt;
  {% for k in headers.keys %}
  &lt;tr&gt;&lt;td&gt; {{ k }} &lt;/td&gt;&lt;td&gt;{{ headers.k }}&lt;/td&gt;&lt;/tr&gt;
  {% endfor %}
  &lt;/table&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;&lt;table border="1"&gt;
  
  &lt;tr&gt;&lt;td&gt; TMP &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt; COMPUTERNAME &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt; wsgi.multiprocess &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt; RUN_MAIN &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt; HTTP_COOKIE &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  ...
  ...
  </code></pre>
  
  <p><strong>Problem:</strong>
  Why is it unable to access <code>{{headers.k}}</code>? </p>
  
  <p>djangobook.com says:</p>
  
  <blockquote>
    <p>Dot lookups can be summarized like this: when the template system
    encounters a dot in a variable name, it tries the following lookups,
    in this order:</p>
  
  <pre><code>Dictionary lookup (e.g., foo["bar"])
  Attribute lookup (e.g., foo.bar)
  Method call (e.g., foo.bar())
  List-index lookup (e.g., foo[2])
  </code></pre>
  </blockquote>
  
  <p>So, <code>headers.k</code> must first match the <strong>dictionary lookup</strong> since headers is a dictionary. Right?</p>
  
  <p>What am I missing</p>