Nested list in template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<ul>
{% for object in object_list %}
  {% ifchanged object.category %}   
    {% if not forloop.first %}
      </ul></li>
    {% endif %}
    <li><h2>{{ object.category }}</h2><ul>
  {% endifchanged %}
    <li><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></li>
  {% if forloop.last %}
    </ul></li>
  {% endif %}
{% endfor %}
</ul>

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.