Given a model like this (much simplified): class Event(models.Model): name = models.CharField(max_length=50)
class Text(models.Model): name = models.CharField(max_length=50) event = models.ForeignKey(Event) name = models.CharField(max_length=50) class TextRange(models.Model): text = models.ForeignKey(Text) start = IntegerField() end = IntegerField() I would like to be able to produce a ValueQuerySet object, would allow me to iterate in a nested for, in some such way as this (which obviously doesn't work): events = Event.objects.values() for event in events: print 'Event Name: %s' % event.name for text in events.text_set: print 'Text Name: %s' % text.name for textrange in text.textrange_set: print'Text Range: %s - %s' % (textrange.start, textrange.end) Basically, the idea is that values() would return a dictionary which also contains related records as a list of dictionaries which can then be further iterated on through to the end. The idea is that I am trying to display a hierarchical list in a view, and do not want the view making repeated queries. I don't like it when views are querying the database. I understand that I can pull in the related fields from the bottom up, due to the qs-rf merge. However, I need to iterate from the top down. Since I need all the related data, it makes sense to do so in a large query, rather than tons of small ones, and avoid hitting the database repeatedly in the view. Suggestions? --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---