Re: Is a Complex filter with __in and __exact possible?

2018-04-09 Thread Tassilo Karge
Probably I should not post into a ten-year old thread, but it was this thread which helped me in my problem, so I want to share my solution to the problem in case anyone else finds this. Am Samstag, 7. März 2009 06:00:55 UTC+1 schrieb Malcolm Tredinnick: > > One day I'll stop posting in this

Re: Is a Complex filter with __in and __exact possible?

2009-03-06 Thread Malcolm Tredinnick
One day I'll stop posting in this thread. Really. On Sat, 2009-03-07 at 12:03 +1100, Malcolm Tredinnick wrote: > However, find things that are simultaneously in all those categories can > be done without all the annotation nonsense I posted. Simply > > >

Re: Is a Complex filter with __in and __exact possible?

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 00:11 -0800, Daniel Hepper wrote: > > > Book.objects.filter(Q(categories=1), Q(categories=2), Q(categories=3)) > > > > Not if you were trying to solve the original poster's question. Your > > query is exactly the same as what he tried to do originally. > > I played a bit

Re: Is a Complex filter with __in and __exact possible?

2009-03-06 Thread Daniel Hepper
> > Book.objects.filter(Q(categories=1), Q(categories=2), Q(categories=3)) > > Not if you were trying to solve the original poster's question. Your > query is exactly the same as what he tried to do originally. I played a bit with the query and just wanted to clarify that it is not exactly the

Re: Is a Complex filter with __in and __exact possible?

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 07:13 -0800, Daniel Hepper wrote: > Yes, this does obviously not work as expected. Sorry for the > misinformation. > > But would it work if every condition was encapsulated in a Q-object? > > Book.objects.filter(Q(categories=1), Q(categories=2), Q(categories=3)) Not if

Re: Is a Complex filter with __in and __exact possible?

2009-03-05 Thread Daniel Hepper
Yes, this does obviously not work as expected. Sorry for the misinformation. But would it work if every condition was encapsulated in a Q-object? Book.objects.filter(Q(categories=1), Q(categories=2), Q(categories=3)) -- Daniel On Mar 5, 4:14 am, Malcolm Tredinnick

Re: Is a Complex filter with __in and __exact possible?

2009-03-04 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 14:19 +1100, Malcolm Tredinnick wrote: [...] > Second version: I want books that are in all three categories, but just > those three categories and *no others*. > > Answer: hmmm... :-( > > This one is possible in raw SQL, but it's a fairly fiddly query. I can't > make it

Re: Is a Complex filter with __in and __exact possible?

2009-03-04 Thread Malcolm Tredinnick
On Wed, 2009-03-04 at 09:58 -0800, Alfonso wrote: > I've set up a simple filter to grab a queryset of objects matching a > list of (many to many) categories like this: > > Book.objects.filter(categories__in=[1,2,3]).order_by('name').distinct > () > > It's good, it works... it returns any books

Re: Is a Complex filter with __in and __exact possible?

2009-03-04 Thread Malcolm Tredinnick
On Wed, 2009-03-04 at 15:06 -0800, Daniel Hepper wrote: > You can try this query: > > Book.objects.filter(categories=1,categories=2,categories=3) > > Hope that helps It won't. A filter() method is a normal Python function or method call. You can only specify each keyword argument exactly once.

Re: Is a Complex filter with __in and __exact possible?

2009-03-04 Thread Daniel Hepper
You can try this query: Book.objects.filter(categories=1,categories=2,categories=3) Hope that helps -- Daniel On 4 Mrz., 18:58, Alfonso wrote: > I've set up a simple filter to grab a queryset of objects matching a > list of (many to many) categories like this: > >

Is a Complex filter with __in and __exact possible?

2009-03-04 Thread Alfonso
I've set up a simple filter to grab a queryset of objects matching a list of (many to many) categories like this: Book.objects.filter(categories__in=[1,2,3]).order_by('name').distinct () It's good, it works... it returns any books in those three categories.But I'd like to return ONLY Books with