How to select many to one to many without hundreds of queries using Django ORM?
My database has the following schema: class Product(models.Model): pass class Tag(models.Model): product = models.ForeignKey(Product) attr1 = models.CharField() attr2 = models.CharField() attr3 = models.CharField() class AlternatePartNumber(models.Model): product = models.ForeignKey(Product) In other words, a Product has many Tag s, and a Product has many AlternatePartNumber s. Tag s are a collection of attributes of the Product . Given the three attributes in a Tag , I want to select the associated Product s that match (could be more than one), as well as all of the AlternatePartNumber s of