I'm developing a forum and my db schema is roughly equivalent to the following: class Topic(models.Model): head = models.CharField() body = models.TextField() created = models.DateTimeField(auto_now_add=True)
class Post(models.Model): body = models.TextField() topic = models.ForeignKey(Topic) created = models.DateTimeField(auto_now_add=True) The question is: how to construct a query to fetch 20 latest Topics with 5 latest Posts for each of these Topics ? As I understood, prefetch_related isn't suitable since it cannot limit the number of related objects. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.