Re: Searching a list of Q

2009-02-26 Thread Malcolm Tredinnick
On Wed, 2009-02-25 at 10:41 -0800, Kevin Audleman wrote: > Ah, gotcha. > > Maybe django should include a iin function =) We already do. It's spelled reduce(operator.or, [...], Q()). :-) Databases don't support inexact IN matching, so Django doesn't support it directly. Wrapping what is already

Re: Searching a list of Q

2009-02-25 Thread Kevin Audleman
Ah, gotcha. Maybe django should include a iin function =) Kevin On Feb 25, 10:37 am, Alex Gaynor wrote: > On Wed, Feb 25, 2009 at 1:34 PM, Kevin Audleman > wrote: > > > > > > > What about the following? > > > qset = Q(author__in=[u"Foo",

Re: Searching a list of Q

2009-02-25 Thread Alex Gaynor
On Wed, Feb 25, 2009 at 1:34 PM, Kevin Audleman wrote: > > What about the following? > > qset = Q(author__in=[u"Foo", u"Bar"]) > > > Kevin > > On Feb 25, 10:03 am, Peter Bengtsson wrote: > > This works: > > > > >>> from django.db.models import Q > >

Re: Searching a list of Q

2009-02-25 Thread Kevin Audleman
What about the following? qset = Q(author__in=[u"Foo", u"Bar"]) Kevin On Feb 25, 10:03 am, Peter Bengtsson wrote: > This works: > >  >>> from django.db.models import Q >  >>> qset = Q(author__iexact=u"Foo") | Q(author__iexact=u"Bar") >  >>> Books.objects.filter(qset) > >

Re: Searching a list of Q

2009-02-25 Thread Alex Gaynor
On Wed, Feb 25, 2009 at 1:03 PM, Peter Bengtsson wrote: > > This works: > > >>> from django.db.models import Q > >>> qset = Q(author__iexact=u"Foo") | Q(author__iexact=u"Bar") > >>> Books.objects.filter(qset) > > But what if the list of things I want to search against is a

Searching a list of Q

2009-02-25 Thread Peter Bengtsson
This works: >>> from django.db.models import Q >>> qset = Q(author__iexact=u"Foo") | Q(author__iexact=u"Bar") >>> Books.objects.filter(qset) But what if the list of things I want to search against is a list. E.g. >>> possible_authors = [u"Foo", u"Bar"] ??? I have a solution but it's