diff options
| author | Ryan Heard <ryanwheard@gmail.com> | 2021-07-02 15:09:13 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-04 12:55:37 +0100 |
| commit | c6b4d62fa2c7f73b87f6ae7e8cf1d64ee5312dc5 (patch) | |
| tree | 238bd8c3045c8d4577e09bd913de9748dcd49968 /django/db/models/query_utils.py | |
| parent | 795da6306a048b18c0158496b0d49e8e4f197a32 (diff) | |
Fixed #29865 -- Added logical XOR support for Q() and querysets.
Diffstat (limited to 'django/db/models/query_utils.py')
| -rw-r--r-- | django/db/models/query_utils.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 6ea82b6520..fde686b2cd 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -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) |
