title: Django templates: How to access a form field equal to a variable value?
body: <p>Imagine a following use case: I have a dictionary of report templates. Each report template has an ID and a name. It looks more or less like this:</p>
  
  <pre><code>reports = [ { 'ID' : 'A1',
                'NAME' : 'special report 1 for department A',
                ... (other fields irrelevant to the question's matter)
              },
              { 'ID' : 'X9',
                'NAME' : 'special report 9 for department X',
                ... (other fields irrelevant to the question's matter)
              },
            ]
  </code></pre>
  
  <p>Access to and visibility of the reports are to be stored in a database.<br>
  I created a form with field names equal to reports' IDs. And everything goes fine until the moment I have to show the form in the template. I don't know how to access the proper form's field. This syntax doesn't work:</p>
  
  <pre><code>{% for report in reports %}
  &lt;tr&gt;
      &lt;td&gt;{{ report.ID }}&lt;/td&gt;
      &lt;td&gt;{{ report.NAME }}&lt;/td&gt;
  
      &lt;td&gt;{{ form.report.ID }}&lt;/td&gt;
  
  &lt;/tr&gt;
  {% endfor %} 
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>{% for report in reports %}
  &lt;tr&gt;
      &lt;td&gt;{{ report.ID }}&lt;/td&gt;
      &lt;td&gt;{{ report.NAME }}&lt;/td&gt;
      {% with report.ID as key %}     
      &lt;td&gt;{{ form.key }}&lt;/td&gt;
      {% endwith %}
  &lt;/tr&gt;
  {% endfor %} 
  </code></pre>
  
  <p>doesn't work.</p>
  
  <p>How should the syntax look like? What should be placed instead of the question marks in the code below?</p>
  
  <pre><code>{% for report in reports %}
  &lt;tr&gt;
      &lt;td&gt;{{ report.ID }}&lt;/td&gt;
      &lt;td&gt;{{ report.NAME }}&lt;/td&gt;
  
      &lt;td&gt;{{ form.??? }}&lt;/td&gt;
  
  &lt;/tr&gt;
  {% endfor %} 
  </code></pre>
  
  <p>I crossed upon this solution: <a href="https://stackoverflow.com/questions/4993625/django-templates-form-field-name-as-variable">Django Templates: Form field name as variable?</a> and I guess I'll have to use it if there won't be any other way to solve my problem. </p>