[...]
> > Doesn't work either. This one returns no results, just like chaining
> > filters.
> >
> I think the above was just a clue, if you need "OR" condition instead
> of "AND", you need to use "|" not "&" so:
>
> Project.objects.filter(Q(persons=persons_a) | Q(persons=persons_b))
If this is the case, then the original problem description was
incorrect.
Mikkel: you said you wanted projects containing person_a *and* person_b,
which is what the chaining filters and Q() & Q() version is giving you.
If they're returning no results, it's because no results exist.
The above filter -- Q() | Q() -- is going to return projects that
contain person_a *or* person_b. Is that what you're after?
Regards,
Malcolm
Gees... It messed with my link. I'll try again:
It works OK here. I have added __rerpr__ method to models to get a clear output:On Sun, Mar 15, 2009 at 2:54 PM, 3xM <3...@detfalskested.dk> wrote:
Gees... It messed with my link. I'll try again:
Oh, dear. If the original poster is using 0.96, then this has little
chance of working. Complex queries involving many-to-many objects didn't
work well there at all. It was an area of many bugfixes between 0.96 and
1.0.
Regards,
Malcolm
>
I'll upgrade to Ubuntu 8.10 (with django 1.0) as soon as possible and
get back to tell if solved the problem.
Sorry for wasting your time if this is what is wrong.
Um ... 1.1 doesn't exist yet. All the necessary query improvements are
in 1.0.2, though. So that's the point to aim for.
Regards,
Malcolm
>
At which point, he can probably just install the .deb from the debian
lenny repository (Chris Lamb has been really on the ball in getting the
releases through recently, and many thanks to him!).
http://packages.debian.org/lenny/all/python-django/download
Cheers,
--
Brett Parker