On Tue, Oct 19, 2010 at 3:46 PM, Ed <edmund.rog...@gmail.com> wrote: > I have 3 tables: studio, film, images. If film has a foreign key to > studio, and images has a foreign key to film. If I wanted to pull all > of the images for a particular studio, it would be more expensive to > pull:
what i do is: in the view, get the images of the studio, ordered by film: images_queryset = image.objects.filter(film__studio_id==studioid).order_by('film') in the template, iterate through the images and show the film whenever it changes: {% for img in images_queryset.all %} {% ifchanged img.film %} ...show the film data.... {% endifchanged %} .... show the image... {% endfor %} -- 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-us...@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.