Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field

Thanks weidwonder for the report.
This commit is contained in:
Claude Paroz 2016-08-02 17:27:45 +02:00
parent 7bc5274f6f
commit 272eccf7ff
3 changed files with 17 additions and 1 deletions

View file

@ -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),
['<Eaten: apple at lunch>']
)
self.assertQuerysetEqual(
Eaten.objects.filter(food__isnull=True),
['<Eaten: None at lunch>']
)
class ConditionalTests(BaseQuerysetTest):
"""Tests whose execution depend on different environment conditions like