mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field
Thanks weidwonder for the report.
This commit is contained in:
parent
7bc5274f6f
commit
272eccf7ff
3 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue