Hi,

I'm trying to optimize some queries I'm making, but I'm not sure how
to do it.

 61             for t in items:
 62                 try:
 63                     t.price = t.user_item_rel_set.get
(user=u).payment_amount
 64                 except:
 65                     t.price = -1 * t.buyer_item_rel_set.get
(buyer=u).payment_amount
 66             return items
 67

user_item_rel_set is a m2m relationship between the User and Item
class.  For every item, I look back at its m2m relationship model and
retrieve payment_amount.  The only problem is, select_related()
doesn't grab the user_item_rel_set.all() when I query for the items
(where items=Item.objects.select_related().all() ).  Is there anything
I can do to speed this up? It's *very* slow.

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

Reply via email to