title: Django template iterate over nested lists
body: <p>In Django, how do we iterate over lists in template for something like <code>[[1,[2,[3]],[4,[]]],[2,[3]]]</code>.</p>
  
  <p>Please note that the above is just a random example. Each element of list can have any number of nested lists further inside. I would like to iterate through each and every value inside and also have an idea of what is the parent so that we can appropriately style the HTML.</p>
  
  <p>Although there is one way to generate HTML in the view itself by recursion and use the corresponding variable in template, this makes the django template and view dependent which is not desired(<a href="https://docs.djangoproject.com/en/dev/misc/design-philosophies/#loose-coupling" rel="nofollow">loose coupling principle</a>). One example of using views is <a href="https://stackoverflow.com/questions/4277243/nested-conversation-list-with-django">here</a> but a representation in template system itself would be better than this type of implementation.</p>