Code

Ticket #7312: complex_filter_q.diff

File complex_filter_q.diff, 617 bytes (added by emulbreh, 6 years ago)
Line 
1Index: django/db/models/query.py
2===================================================================
3--- django/db/models/query.py   (revision 7544)
4+++ django/db/models/query.py   (working copy)
5@@ -398,7 +398,9 @@
6         and usually it will be more natural to use other methods.
7         """
8         if isinstance(filter_obj, Q) or hasattr(filter_obj, 'add_to_query'):
9-            return self._filter_or_exclude(None, filter_obj)
10+            clone = self._clone()
11+            clone.query.add_q(filter_obj)
12+            return clone
13         else:
14             return self._filter_or_exclude(None, **filter_obj)
15