title: Django template nested for loop
body: <p>I have 2 tables:</p>
  
  <pre><code>Table1: [A-Foriegn Key, field1]
  Table2: [Table1-Foriegn Key, field2]
  </code></pre>
  
  <p>I want to display a list with distinct values of Table1 field1 if items are present in Table2. and inside that list I want to display all the elements of Table2 corresponding to that field1 of Table1.</p>
  
  <p>I am trying :</p>
  
  <pre><code>{% for t1 in Table1 %}
     Display field1 of t1
     {% for t2 in Table2 %}
        Display field2 of t2.
     {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>Table 1:</p>
  
  <pre><code>╔════╦══════════════╦══════╗
  ║ Id ║  EventName   ║ FK   ║
  ╠════╬══════════════╬══════╣
  ║  1 ║ Christmas    ║  56  ║
  ║  2 ║ Black Friday ║  18  ║
  ╚════╩══════════════╩══════╝
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>╔════╦══════════════╦══════╗
  ║ ID ║  Image       ║ FK   ║
  ╠════╬══════════════╬══════╣
  ║  1 ║ image1_url   ║  1   ║
  ║  2 ║ image2_url   ║  1   ║
  ║  3 ║ image3_url   ║  2   ║
  ║  4 ║ image4_url   ║  2   ║
  ╚════╩══════════════╩══════╝
  </code></pre>
  
  <p>I want to display : Christmas and BlackFriday in a list.</p>
  
  <p>And on clicking element from the list, I want to display all url for that particular event. 
  Like on clicking Christmas: image1_url and image2_url should be displayed.</p>
  
  <p>I dont want to make AJAX requests.</p>