Re: How to add an OR criterion to an existing QuerySet?

2018-03-15 Thread Simon Charette
Bernd, Glad you managed to achieve what you were after! Combination of querysets is definitely an obscure part or the ORM API. I couldn't even find a single mention of it in the documentation even if I know it's supported. It might be worth opening a ticket about it if you can't find any mentio

Re: How to add an OR criterion to an existing QuerySet?

2018-03-14 Thread Bernd Wechner
Simon, Thanks enormously. A little experimentation and I got that to work! Brilliant. Am most pleased it was possible. Good ol' Django to the rescue. The thing I got stuck on for a bit was an assertion failure because qs was DISTINCT and the or'ed qs was not (the or operation raises a rather

Re: How to add an OR criterion to an existing QuerySet?

2018-03-14 Thread Simon Charette
Hello Bern, You're actually pretty close to the solution. You should be able to OR an existing querysets filters by using the "|" operator between querysets of the same model. That would be the following: qs |= Model.objects.filter(Q(...)) Simon Le mercredi 14 mars 2018 23:45:41 UTC-4, Bernd

How to add an OR criterion to an existing QuerySet?

2018-03-14 Thread Bernd Wechner
Another interesting problem. Let's say I have a QuerySet which already applies some filters. It's provided by a third party library mind you, and all you have is the QuerySet instance. Now I would like to loosen the filter a bit, ad an ORed filter. Not a trivial thing it seems. Q objects aren