1👍
✅
You have to build the datastructure yourself. What you want is essentialy two queries and you cant fetch that in one call.
data = {"collection":None, "sales":[]}
for coll in Collection.objects.filter(sales__status="ACTIVE"):
data["collection"] = coll
for collsales in coll.collectionsales_set.filter(status="ACTIVE")
data["sales"].append(collsales.collection)
Source:stackexchange.com