I believe that this is due to the fact that the last Q is performing
an INNER JOIN on the Authors table, and therefore is excluding all
records that do not have an entry in your (what I assume is a)
ManyToManyField/ForeignKey.

On Aug 2, 5:37 pm, LaundroMat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Suppose I have defined the models from the django documentation
> (http://www.djangoproject.com/documentation/db-api/).
>
> I'm performing a search the entries model, and I want to look through
> all of its fields:
>
> from django.db.models import Q
> query =
> 'querystring'                                                     #
> User supplied querystring, eg "Lawrence"
> lookup = Q(headline__icontains = querystring) | \
>                 Q(body_text__icontains = querystring) | \
>                 Q(authors__name__icontains = querystring)
>
> p = Prediction.objects.filter(lookup).distinct()
>
> The models I have built are more complex than the above, but the gist
> is the same. For one reason or another, I get more results when I
> leave out the last Q object (the one looking through the authors'
> names) than when I leave it in. This shouldn't be happening, as all Q
> objects are being OR'ed.
>
> I hope I've given enough information for you to try and simulate my
> problem, and perchance find a solution for it. Many thanks in advance
> already.
>
> Mathieu


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to