Wouldn't the following code solve the problem without Q objects? Offer.objects.filter(searchterms__term='ThemePark', searchterms__term='London')
According to the docs the filter parameters are AND'ed. Admittedly I never used this in combination with ManyToMany fields, so I might be wrong here. peter On 17 Sep., 19:31, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > What version of django are you using? > > I am using the latest from svn and this does work for me, however I just > looked at your model definitions again and realized that the query I sent > you would not work. I didn't notice that in your Offer model the related > name is 'searchterms', not 'terms', so if you did not catch that already > try: > > Offer.objects.filter(Q(searchterms__term__exact = 'ThemePark') & > Q(searchterms__term__exact = 'London')) , although if it is returning an > empty query set and not failing, you probably did catch my error. > > If this does not work, have you tried instantiating the Terms objects and > passing them to the query, (obviously not an efficient way of doing this but > may provide some insight into whether or not the m2m query works), i.e. > > t1 = Terms.objects.get(term__exact = 'ThemePark') > t2 = Terms.objects.get(term__exact = 'London') > Offer.objects.filter(Q(searchterms = t1) & Q(searchterms = t2)) > > -richard --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---