title: Accordion Table Django Template
body: <p>I'm trying to have a table populated by objects in a database from a Django model (I have this), then when a row is clicked, to use JS (or JQuery) to accordion a table of objects that are foreign keys to the first object.</p>
  
  <p>Thanks in advance;</p>
  
  <p>Django Template for the table</p>
  
  <pre><code> {% if objects %}
            &lt;div class="table-responsive"&gt;
              &lt;table class="table table-striped"&gt;
                &lt;thead&gt;
                  &lt;tr&gt;
                    &lt;th&gt;Id&lt;/th&gt;
                    &lt;th&gt;Name&lt;/th&gt;
                    &lt;th&gt;Time&lt;/th&gt;
                    &lt;th&gt;Field 1&lt;/th&gt;
                    &lt;th&gt;v&lt;/th&gt;
                    &lt;th&gt;Field 2&lt;/th&gt;
                      &lt;div&gt;
  
                      &lt;/div&gt;
                  &lt;/tr&gt;
  
                &lt;/thead&gt;
                &lt;tbody&gt;
                  {% for object in objects %}
                      &lt;tr&gt;
                          &lt;th&gt;{{object.object_id}}&lt;/th&gt;
                          &lt;th&gt;{{object.name}}&lt;/th&gt;
                          &lt;th&gt;{{object.time}}&lt;/th&gt;
                          &lt;th&gt;{{object.field1}}&lt;/th&gt;
                        &lt;th&gt;v&lt;/th&gt;
                        &lt;th&gt;{{object.field2}}&lt;/th&gt;
                      &lt;/tr&gt;
                  {% endfor %}
                &lt;/tbody&gt;
              &lt;/table&gt;
            &lt;/div&gt;
          {% else %}
              &lt;p&gt;No objects!&lt;/p&gt;
          {% endif %}
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>class Object(models.Model):
      object_id = models.IntegerField()
      name = models.CharField(max_length=50)
      object_type = models.CharField(max_length=25)
      time = models.DateTimeField()
      field1 = models.CharField(max_length=50)
      field2 = models.CharField(max_length=50)
      featured = models.BooleanField(default=False)
  
  
  class Child(models.Model):
      child_id = models.IntegerField()
      name = models.CharField(max_length=50)
      description = models.CharField(max_length=200)
      field11 = models.FloatField()
      field12 = models.ForeignKey('Object')
  </code></pre>