On 09/03/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> thanks for your response.
>
> well, i am trying to get a list of dependents of a given object in a
> single query. i want to be able to retrieve the dependents by key (the
> object name) from this list.
>
> i do not see any way of doing this but getting the query set and
> converting it to a dictionary manually:
>
> d = dict()
> for x in AB.objects.select_related().filter(aa__name = 'aa')  :
>     y = x.bb
>     d[y.name] = y
>
> i was trying to avoid this extra list traversal...
>
> konstantin

I'm still a little bit confused, but here's what I'd suggest:

In the model you've described you can say something like:
BB.objects.filter(ab__aa__name="aa") to get the list of BB objects
that are mapped to that specific AA object.

In addition - if you don't have other fields in the AB model,
substitute that with a M2M field in one of the AA or BB models.  It
will allow you to use the full M2M relationship syntax in your
QuerySets.

Finally - those model names are giving us headaches. Sometimes it
helps a lof if you ask your questions in the context of your system
and people might have more clues and ideas for you.

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to