Check out the docs about many-to-many relationships. The link below  
talks exactly about what you are asking.

http://www.djangoproject.com/documentation/db_api/#many-to-many- 
relations

On Mar 18, 2006, at 8:05 AM, Ned Batchelder wrote:

>
> I want to select objects based on their relationships with related
> objects, but I don't seem to be able to do it, because I'm trying  
> to use
> a foreign key in the "wrong" direction.  For example, in the Polls and
> Choices model, I can do this (from the docs):
>
>    choices.get_list(poll__slug__exact="eggs")
>
> This works because the Choice class has a poll ForeignKey.  But I  
> can't
> get a list of polls based on the characteristics of choices:
>
>    polls.get_list(choice__choice__exact="overeasy")   # Doesn't work.
>
> Am I wrong?  Please tell me there is a way to accomplish what I want.
> This is all in .91.  I can manage it with trapdoor params like where=:
>
>    polls.get_list(where=["id in (SELECT poll_id FROM app_choices where
> choice='overeasy')"])
>
> Or something like that, I'm backtranslating from my real app.  Is  
> there
> a cleaner way?
>
> Thanks.
>
> --Ned.
>
> -- 
> Ned Batchelder, http://nedbatchelder.com
>
>


--~--~---------~--~----~------------~-------~--~----~
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