MCPcopy
hub / github.com/django/django / complex_filter

Method complex_filter

django/db/models/query.py:1683–1698  ·  view source on GitHub ↗

Return a new QuerySet instance with filter_obj added to the filters. filter_obj can be a Q object or a dictionary of keyword lookup arguments. This exists to support framework features such as 'limit_choices_to', and usually it will be more natural to use o

(self, filter_obj)

Source from the content-addressed store, hash-verified

1681 self._query.add_q(Q(*args, **kwargs))
1682
1683 def complex_filter(self, filter_obj):
1684 """
1685 Return a new QuerySet instance with filter_obj added to the filters.
1686
1687 filter_obj can be a Q object or a dictionary of keyword lookup
1688 arguments.
1689
1690 This exists to support framework features such as 'limit_choices_to',
1691 and usually it will be more natural to use other methods.
1692 """
1693 if isinstance(filter_obj, Q):
1694 clone = self._chain()
1695 clone.query.add_q(filter_obj)
1696 return clone
1697 else:
1698 return self._filter_or_exclude(False, args=(), kwargs=filter_obj)
1699
1700 def _combinator_query(self, combinator, *other_qs, all=False):
1701 # Clone the query to inherit the select list and everything

Callers 6

get_querysetMethod · 0.80
get_choicesMethod · 0.80
validateMethod · 0.80
get_choicesMethod · 0.80
test_ticket7235Method · 0.80
test_complex_filterMethod · 0.80

Calls 3

_chainMethod · 0.95
_filter_or_excludeMethod · 0.95
add_qMethod · 0.80

Tested by 2

test_ticket7235Method · 0.64
test_complex_filterMethod · 0.64