Anyone have any ideas? q2 and q3 should return the same results.
>>> from testing.models import Building >>> from testing.models import Unit >>> b1 = Building(name="Bld 1") >>> b1.save() >>> u1 = Unit(building=b1,bedrooms=1,bathrooms=1) >>> u1.save() >>> u2 = Unit(building=b1,bedrooms=2,bathrooms=3) >>> u2.save() >>> q1 = Building.objects.filter(unit__bedrooms=1) >>> q2 = q1.filter(unit__bathrooms=3) >>> q3 = Building.objects.filter(unit__bedrooms=1,unit__bathrooms=3) >>> >>> print q2 [<Building: Building object>] >>> print q3 [] >>> print q2.query.as_sql() ('SELECT "testing_building"."id", "testing_building"."name" FROM "testing_building" INNER JOIN "testing_unit" ON ("testing_building"."id" = "testing_unit"."building_id") INNER JOIN "testing_unit" T3 ON ("testing_building"."id" = T3."building_id") WHERE ("testing_unit"."bedrooms" = %s AND T3."bathrooms" = %s )', (1, 3)) >>> print q3.query.as_sql() ('SELECT "testing_building"."id", "testing_building"."name" FROM "testing_building" INNER JOIN "testing_unit" ON ("testing_building"."id" = "testing_unit"."building_id") WHERE ("testing_unit"."bedrooms" = %s AND "testing_unit"."bathrooms" = %s )', (1, 3)) >>> --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---