> > Yes, you are right. I was not thinking straight. Not a problem. Help is always appreciated!
> > Anyone know what the > > best method for performing this in SQL would be? Select all posts for > > each tag and use intersect? > > With ManyToMany relationships, you have to think of chasing the > relationship backwards. Instead of finding the posts with a given tag, > start with the tag and find the related posts: > > >>> from danet.blog.models import Post, Tag > >>> t = Tag.objects.get(pk='programming') > >>> t.post_set.all() > [<Post: ASP.NET 2.0>, <Post: Code Highlighting>] > >>> That works easily when you're just looking up one Tag. What I'm trying to figure out is the best way to search for multiple tags and return only the Posts common to all of those tags: >>> from danet.blog.models import Post, Tag >>> t = Tag.objects.get(pk='programming') >>> t2 = Tag.objects.get(pk='ASP') >>> t.post_set.all() [<Post: ASP.NET 2.0>, <Post: Code Highlighting>] >>> t2.post_set.all() [<Post: ASP.NET 2.0>] So I guess now the question is how to generate a list that contains items only contained in each of the tag lists. I'm sure some simple python can take care of that. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---