You are missing Q. try from django.db.models import Q (I think that is where it resides but cannot verify right now, a quick check of the documentation should confirm)
Offer.objects.filter(Q(terms__exact = 'term1') & Q(terms__exact = 'term2') & Q(terms__exact = 'term3)) On Sep 14, 6:46 pm, Merric Mercer <[EMAIL PROTECTED]> wrote: > I have a model "OFFER" that has has many to many relationship with a > model "TERMS". > > Class OFFER: > terms=models.ManyToMany(Terms) > > Assuming I have the following value for 3 records in Term > term1=2 > term2=5 > term3=8 > > I want to return ONLY those offers which have ALL three of these terms . > I've tried: > > qs=Offer.objects.all().filter(terms=term1).filter(terms=term2).filter(terms=term3) > but this doesn't work - I always end up with an empty query set. > > What am I missing? > > Cheers --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---