Wednesday, August 1, 2012

Re: union of two QuerySets

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_name__startswith='joh')

In [8]: a + b

Thanks a lot,
Ray


Try:

a | b

 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ie69j4ewJNUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment