views:

38

answers:

1

Is there a fast and easy way to do this? I haven't been able to find anything that's already out there that seems to do this already.

Since it's a queryset, i don't think i can use the unique properties of Set to solve the problem either. any ideas?

+2  A: 

Use Q objects, one for each query, and OR them together. Then, use distinc()

qs = SomeModel.objects.get(Q(some_attribute=something) |
                           Q(some_other_attribute=something)).distinct()
Chris Lawlor
interesting, thanks! unfortunately i'm using a backend that doesn't support the "OR" keyword, so it can't execute this as one query statement, but two completely separate ones. I haven't been able to figure out a way to use the distinct on two completely separate queries
Well, if you don't need a queryset in return, you could just do results = set(list(qs1) + list(qs2)).
Chris Lawlor