title: Output nested list to xlsx using Django
body: <p>I have a complex nested list of models that looks like this:</p>
  
  <pre><code>hierarchy_tree =  ['0000', 'hierarchy' [['0000-22', 'hierarchy2', [['0000-33', 'hiearchy3', [['0000-44-4444', 'hiearchy4', [['0000-55-5555-55', 'hiearchy5', []]]]]]]]]]
  </code></pre>
  
  <p>I am able to easily display this in a template using dot notation - example:</p>
  
  <pre><code>{% for hierarchy in hierarchy_tree %}
              &lt;tr class="item" data-id="{{system.0}}" data-parent=""&gt;
                  &lt;td&gt;
                      {{hierarchy.0}}
                  &lt;/td&gt;
                  &lt;td&gt;
                      {{hierarchy.1.genericname}}
                  &lt;/td&gt;
  </code></pre>
  
  <p>Now I am trying to output this to an .xlsx file but I cannot figure out how to pass all of the levels of this list? How can I do the same thing that I did in the template to pass this list to excel?</p>
  
  <p>I have tried the following which will return the 1st list but throws an error (ValueError at /post/1/export/hierarchy/ - cannot covert(my passed in list)to excel) for the sublists because of the way that they are nested I believe.</p>
  
  <pre><code>for r in hierarchy_tree:
      ws.append(r)
  </code></pre>
  
  <p>I have also tried and failed repeatedly to access the sublists using other methods.</p>
  
  <p>So bottom line I need to figure out how to access and pass the values for the sublists - any ideas or help will be greatly appreciated?</p>
  
  <p>Thank you</p>