mirror of
https://github.com/django/django.git
synced 2025-08-12 14:58:20 +00:00
Fixed #29865 -- Added logical XOR support for Q() and querysets.
This commit is contained in:
parent
795da6306a
commit
c6b4d62fa2
19 changed files with 311 additions and 18 deletions
|
@ -38,6 +38,7 @@ class Q(tree.Node):
|
|||
# Connection types
|
||||
AND = "AND"
|
||||
OR = "OR"
|
||||
XOR = "XOR"
|
||||
default = AND
|
||||
conditional = True
|
||||
|
||||
|
@ -70,6 +71,9 @@ class Q(tree.Node):
|
|||
def __and__(self, other):
|
||||
return self._combine(other, self.AND)
|
||||
|
||||
def __xor__(self, other):
|
||||
return self._combine(other, self.XOR)
|
||||
|
||||
def __invert__(self):
|
||||
obj = type(self)()
|
||||
obj.add(self, self.AND)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue