mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().
This allows using expressions that have an output_field that is a BooleanField to be used directly in a queryset filters, or in the When() clauses of a Case() expression. Thanks Josh Smeaton, Tim Graham, Simon Charette, Mariusz Felisiak, and Adam Johnson for reviews. Co-Authored-By: NyanKiyoshi <hello@vanille.bid>
This commit is contained in:
committed by
Mariusz Felisiak
parent
069bee7c12
commit
4137fc2efc
@@ -1327,7 +1327,10 @@ class CaseWhenTests(SimpleTestCase):
|
||||
Case(When(Q(pk__in=[])), object())
|
||||
|
||||
def test_invalid_when_constructor_args(self):
|
||||
msg = '__init__() takes either a Q object or lookups as keyword arguments'
|
||||
msg = (
|
||||
'When() supports a Q object, a boolean expression, or lookups as '
|
||||
'a condition.'
|
||||
)
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
When(condition=object())
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
|
||||
Reference in New Issue
Block a user