Hi, I myself am learning this, but I'd like to take a crack at your
question.
Based on the DB API document, you need to employ both select_related()
(to go from a model with a FK to the objects related by that FK), and
somefield_set (to go the other way).  (Note it seems select_related is
a method on QuerySet that returns a QuerySet, and somefield_set is an
attribute on a QuerySet that is a Manager, which is the same type of
thing as Model.objects - it has methods that return QuerySets.)

So here is something that might work, I have it broken out with
descriptive names so hopefully it is more clear.

words_queryset = Word.objects.filter(value__exact='assam')
productwords_queryset = words_queryset.productword_set
productwords_with_related_queryset =
productwords_queryset.select_related()

products = [p.product for p in
productwords_with_related_queryset.all()]


I hope somebody will correct me if this is mistaken!


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to