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
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
>
>
>
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
> > 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
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
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
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
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
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.
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:
>
>
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
11 matches
Mail list logo