title: how to get family tree using Django template and from ManyToMany field?
body: <p>I need family tree, I'm not using any library here( can you suggest ). First can you look into my model first so you will come to know the idea.</p>
  
  <pre><code>class FamilyMember(models.Model):
      familyname = models.ForeignKey(FamilyName)
      first_name = models.CharField(max_length=50)
      parents = models.ManyToManyField('self', null=True, blank=True, related_name='p', symmetrical=False)
      children = models.ManyToManyField('self', null=True, blank=True, related_name='c', symmetrical=False)
  </code></pre>
  
  <p>And my view function look like</p>
  
  <pre><code>def explore_home(request):
      old_date = FamilyMember.objects.filter(familyname__name = family_name).aggregate(Min('birth_date'))
      member_obj_all = FamilyMember.objects.get(familyname__name = family_name, birth_date=old_date['birth_date__min'])
  </code></pre>
  
  <p>And I am using <code><a href="http://thecodeplayer.com/walkthrough/css3-family-tree" rel="nofollow noreferrer">this code</a></code> for build the family tree.</p>
  
  <p>In my django template I do like</p>
  
  <pre><code>&lt;div class="tree"&gt;
      &lt;ul&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;{{ family_name }}&lt;/a&gt;
              &lt;ul&gt;
                  &lt;li&gt;
                      &lt;a href="#"&gt;{{ member_obj_all }}&lt;/a&gt;
                      {% if member_obj_all.children.all %}
  
                      &lt;!-- here we go again --&gt;
                          &lt;ul&gt;
                              {% for child_obj in member_obj_all.children.all %}
                                  &lt;li&gt;
                                      &lt;a href=""&gt;{{ child_obj }}&lt;/a&gt;
  
                                      {% if child_obj.children.all %}
                                      &lt;!-- here we go againg --&gt;
                                      &lt;ul&gt;
                                          {% for grand_child_obj in child_obj.children.all %}
                                              &lt;li&gt;
                                                  &lt;a href=""&gt;{{ grand_child_obj }}&lt;/a&gt;
                                              &lt;/li&gt;
                                          {% endfor %}
                                      &lt;/ul&gt;
                                      {% endif %}
  
                                  &lt;/li&gt;
                              {% endfor %}
                          &lt;/ul&gt;
                      {% endif %}
                  &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>ok above code working and the output is like ...</p>
  
  <p><img src="https://i.stack.imgur.com/CWUg4.png" alt="enter image description here"></p>
  
  <p>But what if i have n number of children and then children's children and How to automate the process again.? (in template ? ). See i just have this idea and if you have any idea then please tell me here.</p>