class Price(models.Model):
book = models.ForeignKey(Book, related_name='prices')
然后使用它:
books = Book.objects.prefetch_related('prices')
Django:prefetch_related()是否遵循反向关系查找?
class Price(models.Model):
book = models.ForeignKey(Book, related_name='prices')
然后使用它:
books = Book.objects.prefetch_related('prices')