Django conditional Subquery aggregate
问题 An simplified example of my model structure would be class Corporation(models.Model): ... class Division(models.Model): corporation = models.ForeignKey(Corporation) class Department(models.Model): division = models.ForeignKey(Division) type = models.IntegerField() Now I want to display a table that display corporations where a column will contain the number of departments of a certain type, e.g. type=10 . Currently, this is implemented with a helper on the Corporation model that retrieves