[Answer]-Appengine django dynamic table that is possibly empty

1👍

There’s no need for any custom template tags here.

{% for list in lists %}
   {% for item in list.items %}
       {% if forloop.first %}     
           <font size="+2"><b>{{ list.name }}</b></font><br>
           <table><tr><th>&nbsp;</th><th>item</th><th>created</th><th>completed</th></tr>

etc.

All this does is move the header into the inner for loop, and output it on the first iteration only. If the list is empty, it’ll never enter that inner loop, and never output the header.

Leave a comment