From 6757c94662ef07e35eafcf3ac8bdae07a3d9326a Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 2 Aug 2016 17:27:45 +0200 Subject: [1.10.x] Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field Thanks weidwonder for the report. Backport of 272eccf7ff0ced609e5a5e3bb6b4a40e773e0e66 from master. --- tests/queries/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 48b57376f9..a3a810ce5e 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2483,6 +2483,19 @@ class ToFieldTests(TestCase): [node1] ) + def test_isnull_query(self): + apple = Food.objects.create(name="apple") + Eaten.objects.create(food=apple, meal="lunch") + Eaten.objects.create(meal="lunch") + self.assertQuerysetEqual( + Eaten.objects.filter(food__isnull=False), + [''] + ) + self.assertQuerysetEqual( + Eaten.objects.filter(food__isnull=True), + [''] + ) + class ConditionalTests(BaseQuerysetTest): """Tests whose execution depend on different environment conditions like -- cgit v1.3