Aggreate in DB
Aggreate in DB

Uses the annotate feature of Django for counting the orders. This solution only needs c*t*s*2 loops while the old solution loops as often as the number of orders.
d120/pyophase,d120/pyophase,d120/pyophase,d120/pyophase