I am trying to minimize the database hits. Take this example... from django.contrib.auth.models import User
class Group(models.Model): # a bunch of fields here user = models.ForeignKey(User, related_name="groups") class Member(models.Model): # a bunch of fields here user = models.ForeignKey(User, related_name="members") groups= models.ForeignKey(Invitation, related_name="members") Basically the idea of the above is that given a user, you can fetch a list of members. Or, given a group, you can fetch a list of members belonging to that group. In one of my templates, I would like to paginate based on the groups, lets say 10 groups per page. But for each group displayed, I want to also display each member. The groups will be small enough so this won't be ridiculous. I feel confident than this can be done _without_ having to perform 11 queries per page (one for the groups, and then 1 for getting the members of each group). Am I correct? If so, how? Mildly off topic, I am trying to figure out what exactly happens when using MyModel.objects.all(). I understand that it is just an iterable but, using the example of pagination, when you do Paginator (MyModel.objects.all(), 10), is there no database hit until you get a specific page, where it will only fetch the 10 for the page it needs? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---