Ok ORM gurus: my models form a foreign key "chain":
ProductType  <- Product -> Producer -> Region -> Country

My view needs the list of product types for each Producer, Region and
Country. Currently I iterate all producers, regions and countries in
the view and do e.g.

 country.producttypes =
ProductType.objects.filter(product__producer__region__country=country).distinct()

Then I can do {% for producttype in country.producttypes %} in the
template for every country (and region and producer).

But this method fires a whole lot of queries (10-20 ms each), and I'm
looking for an optimization. I have several solutions in mind, but none
of them are elegant. Any thoughts?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to