On May 1, 11:16 am, msoulier <[EMAIL PROTECTED]> wrote: > I have a case where I'm trying to OR several conditions together in a > query, and I'm including a query against a field in a foreign key > field. > > queryset = queryset.filter( > Q(clientid__icontains=filter) | > Q(description__icontains=filter) | > Q(icp__name=filter) > ) > > here, icp is a foreign key, and we're trying to match it's field > "name". > > In some cases, icp is NULL, so there is no corresponding model to > follow, and in those cases, this query always fails to return models > that it otherwise would.
So, I narrowed it down to the OR of the resultant querysets. >>> q1 [<Client: 08:00:0f:0b:aa:32>, <Client: 08:00:0f:16:dc:b0>, <Client: 08:00:0f:16:dc:fe>, <Client: 08:00:0f:1f:f5:ba>] >>> q2 [] >>> q1 | q2 [<Client: 08:00:0f:0b:aa:32>] q2 involves the foreign key lookup where 3 of the objects in q1 have a NULL in that place. Is this not a bug in how the querysets are OR'd? Thanks, Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

