I have models as follows:
class Place(models.Model):
name = models.CharField(max_length=300)
class Person(models.Model):
name = models.CharField(max_length=300)
class Manor(models.Model):
place = models.ManyToManyField(Place, related_name="place"))
lord = models.ManyToManyField(Person, related_name="lord")
overlord = models.ManyToManyField(Person, related_name="overlord")
If I do {{ person.lord.count }} in my template, I can get the count of the Manors attached to each Person.
Is there a way I can do an equivalent of {{ person.lord.place.count }} (which doesn’t work), to get the count of the Places attached to the Manors attached to each Person?
Thanks!
Try this: