Ticket #17600: exclude.r17463.diff
File exclude.r17463.diff, 1.4 KB (added by , 13 years ago) |
---|
-
db/models/query.py
631 631 if args or kwargs: 632 632 assert self.query.can_filter(), \ 633 633 "Cannot filter a query once a slice has been taken." 634 635 634 clone = self._clone() 635 lookup = Q(*args, **kwargs) 636 636 if negate: 637 clone.query.add_q(~Q(*args, **kwargs)) 638 else: 639 clone.query.add_q(Q(*args, **kwargs)) 637 lookup.negate_last_node() 638 clone.query.add_q(lookup) 640 639 return clone 641 640 642 641 def complex_filter(self, filter_obj): -
db/models/query_utils.py
43 43 def __init__(self, *args, **kwargs): 44 44 super(Q, self).__init__(children=list(args) + kwargs.items()) 45 45 46 def negate_last_node(self): 47 if not self.children: 48 return 49 for child in self.children: 50 if not isinstance(child, tree.Node): 51 self.negated = True 52 else: 53 child.negate_last_node() 54 46 55 def _combine(self, other, conn): 47 56 if not isinstance(other, Q): 48 57 raise TypeError(other)