The first query looks at the restaurant attribute in the place model, and gets all that have a NULL value in that field. Now I don't know the restaurant/place setup, the docs I read uses book/auther examples. It looks like that the restaurant field is ForeignKey, and should be able to work the way intended. It would do a lookup for all places that doen't have a restaurant object associate with it. But, if the restaurant field is a BoolianField instead, then you can't use is_null, as both True and False isn't Null.
Hope this helps, else be a little more explicit about the relationships. -Briel On Dec 30, 5:23 am, pk <[email protected]> wrote: > Alex, > > First I made a mistake in the original post. The first query returns > *nothing*, not "all places". This is the correct "question: > > 1) print Place.objects.filter(restaurant__isnull=True).count() > > returns 0 > > and 2) print Place.objects.filter > (restaurant__serves_hotdog__isnull=True).count() > > works correctly, returning a count of all Places that is not a > restaurant. > > The first query does not even join the child table. It tries to do: > > SELECT COUNT(*) FROM "place" WHERE "place"."id" IS NULL > > Where as the second query does a LEFT OUTER JOIN between parent and > child table, then > added a where clause to test for the hotdog field being null, > essentially filtered out the rows > that have no hotdog fields at all. > > Seems like query 1 is broken? > > P.K. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

