wrappers.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:c3nav 作者: c3nav 项目源码 文件源码
def _filter_q(self, q):
        """
        filter by Q object.
        Split it up into recursive _filter_q and _filter_kwarg calls and combine them again.
        :return: new Q object and set of matched existing pks
        """
        if not q.children:
            return q, self._get_initial_created_pks()
        filters, created_pks = zip(*((self._filter_q(c) if isinstance(c, Q) else self._filter_kwarg(*c))
                                     for c in q.children))
        result = Q(*filters)
        result.connector = q.connector
        result.negated = q.negated

        created_pks = reduce(operator.and_ if q.connector == 'AND' else operator.or_, created_pks)
        if q.negated:
            created_pks = self._get_initial_created_pks()-created_pks
        return result, created_pks
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号