Sean Perry wrote: > > I have the following classes in my model: > > class Category: > description = charField() > > class Thing: > self.description = charField() > self.category(ForeignKey, Category) > > I would like a page layed out like: > > Category1 > * foo > * bar > * baz > > CategoryX > * woo > * war > * waz > > etc. > > The {% regroup %} tag looked promising, but I can not get it to work. > > {% regroup user.get_thing_list|dictsort:"category" by category as > grouped %\ > } > {% for category in grouped %} > <p> > {{ category.grouper }} > {% for entry in category.list %} > <!-- handle entry --> > {% endfor %} > </p> > {% endfor %} > > Would:
{% regroup user.get_thing_list|dictsort:"category_id" by category_id as grouped %} {% for category in grouped %} <p> {{ category.list.0.get_category.description }} {% for entry in category.list %} <!-- handle entry --> {% endfor %} </p> {% endfor %} work?