On Thu, Sep 24, 2009 at 2:49 AM, dimitri pater - serpia <dimitri.pa...@gmail.com> wrote: > > Hi, > > say, I have two related models: > > class Author(models.Model): > name = models.CharField() > > class Book(models.Model): > author = models.ForeignKey(Author) > titel = models.CharField() > isbn = models.CharField() > > and I want to group them and display them in a template like this: > > Stephen King: > ========== > Green Mile 7878787 > Four past midnight 909090 > etc.. > > Daphne du Maurier: > ========== > Rebecca 565656 > Don't look now 232323 > etc....
what i usually do is: - in the view just get all the books, ordered by author - in the template iterate over the books, with an {% ifchanged book.author %} to display the author name -- Javier --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---