In your view code, include { 'categories':BookCategory.objects.all () } in your context.
Then, in the template <ul> {% for cat in categories %} <li>{{ cat }} <ul> {% for book in cat.book_set.all %} <li>{{ book }}</li> {% endfor %} </ul> </li> {% endfor %} </ul> This assumes you have the __str__() method of Book and BookCategory set to output something you're happy with. If you'd prefer, you can use {{ cat.name }} and {{ book.name }} (or a similar idea, depending on what the actual field is called in your model) instead. Todd On Aug 5, 2006, at 11:13 AM, [EMAIL PROTECTED] wrote: > > Hi, > > Using the models below, I want a single page to show: > > bookcategory1 > book1 > book2 > bookcategory2 > book1 > book2 > ... > bookcategory3 > ... > ... > ... > > ################################## > > # Models > > class BookCategory(models.Model): > ... > > class Book(models.Model): > ... > category = models.ForeignKey(BookCategory) > ... > > ################################## > > What would be the preferred way to do this? > Can it be done without templatetags? How? > > If the solution must rely on templatetags, can you give me a short > example of how this templatetag might look? > > Thanks very much! > > Best regards, > Cello > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---