Re: union of two QuerySets

2012-08-06 Thread Robin Pedersen
models.Q(first_**name__startswith='joh')) > (only one query...) > > > 2012/8/1 Robin Pedersen <robinpe...@gmail.com> > >> On Monday, December 11, 2006 4:37:25 AM UTC+1, Rares Vernica wrote: >>> >>> Hi, >>> >>> What is

Re: union of two QuerySets

2012-08-01 Thread akaariai
On 1 elo, 19:15, Tim Chase wrote: > On 08/01/12 10:28, lex P rez wrote: > > > Hi, > > > it's better  Person.objects.filter(models.Q(first_**name__startswith='mic'), > > models.Q(first_**name__startswith='joh')) > > (only one query...) > > I'm pretty sure this will

Re: union of two QuerySets

2012-08-01 Thread Tim Chase
On 08/01/12 10:28, Àlex Pérez wrote: > Hi, > > it's better Person.objects.filter(models.Q(first_**name__startswith='mic'), > models.Q(first_**name__startswith='joh')) > (only one query...) I'm pretty sure this will get you the intersection (it uses AND) rather than the union (which would be

Re: union of two QuerySets

2012-08-01 Thread Àlex Pérez
, >> >> What is a way to get the union of two QuerySets? >> >> Something like: >> >> In [6]: a = Person.objects.filter(first_**name__startswith='mic') >> >> In [7]: b = Person.objects.filter(first_**name__startswith='joh') >> >> In [8]:

Re: union of two QuerySets

2012-08-01 Thread Robin Pedersen
On Monday, December 11, 2006 4:37:25 AM UTC+1, Rares Vernica wrote: > > Hi, > > What is a way to get the union of two QuerySets? > > Something like: > > In [6]: a = Person.objects.filter(first_name__startswith='mic') > > In [7]: b = Person.objects.filter(first_nam

Re: Union of two querysets?

2010-02-16 Thread Nick Booker
Yes you can do a union. Use the "|" (pipe) operator. union = queryset1 | queryset2 or you can replace queryset1 with the union as follows: queryset1 |= queryset2 Nick On 16/02/10 02:39, rebus_ wrote: On 16 February 2010 03:28, ydjango wrote: I have two query sets

Re: Union of two querysets?

2010-02-15 Thread rebus_
On 16 February 2010 03:28, ydjango wrote: > I have two query sets with two different where clauses on same table > and same columns in select. Is it possible to have their union. > > I tried qryset = qryset1 + qryset2 >  It gave me - "+ unsupported operand" > > -- > You

Union of two querysets?

2010-02-15 Thread ydjango
I have two query sets with two different where clauses on same table and same columns in select. Is it possible to have their union. I tried qryset = qryset1 + qryset2 It gave me - "+ unsupported operand" -- You received this message because you are subscribed to the Google Groups "Django

Re: union of two QuerySets

2006-12-12 Thread Honza Král
if you want a true union, use chain from itertools on the two querysets... On 12/11/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > On 12/11/06, Rares Vernica <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I know the Q way, but actually the filter contains already a lot of Qs. > > > > I am

Re: union of two QuerySets

2006-12-11 Thread Jeremy Dunck
On 12/11/06, Rares Vernica <[EMAIL PROTECTED]> wrote: > > Hi, > > I know the Q way, but actually the filter contains already a lot of Qs. > > I am looking for a way to combine "a" and "b" without going into their > filters. QuerySets are lazy. There's no downside to combining two

Re: union of two QuerySets

2006-12-11 Thread Rares Vernica
Hi, I know the Q way, but actually the filter contains already a lot of Qs. I am looking for a way to combine "a" and "b" without going into their filters. Thanks Jacob Kaplan-Moss wrote: > On 12/10/06 9:37 PM, Rares Vernica wrote: >> What is a way to get the uni

Re: union of two QuerySets

2006-12-10 Thread Jacob Kaplan-Moss
On 12/10/06 9:37 PM, Rares Vernica wrote: > What is a way to get the union of two QuerySets? See http://www.djangoproject.com/documentation/db_api/#complex-lookups-with-q-objects. > In [6]: a = Person.objects.filter(first_name__startswith='mic') > > In [7]: b = Person.ob