Access to fields of prefetch_related on reverse relation
I have this models
class Animal(models.model):
name = models.Charfield()
class Dog(Animal):
field = models.IntegerField()
class Owner(models.model):
animal = models.ForeignKey(Animal)
name = models.CharField()
Now supose that i want all Dogs and his owner names.
dogs = Dog.objects.all().prefetch_related('ownwer_set')
How do i access owner.name from dogs?
No comments:
Post a Comment