Yuj*_*ita 4 python django django-q
我正在使用看起来像这样的查询:
filters = Q(is_default = False)
# Build the excludes and filters dynamically
if cut:
filters = filters & Q(mailbagstats__num_letters2__gt = int(cut) )
Run Code Online (Sandbox Code Playgroud)
鉴于filters Q查询,我可以查询pop其中一个吗?
我想Q(mailbagstats__num_letters2__gt= int(cut) )从此Q查询中删除查询,以获取新的过滤器.
通常情况下,我使用列表,reduce但这个是通过构造, Q() & Q()所以我不知道如何修改它.
感谢您提供的任何输入!
你可以pop:
>>> filter = Q(a=True)
>>> filter = filter & Q(b=True)
>>> filter.children
[('a', True), ('b', True)]
>>> filter.children.pop()
('b', True)
>>> filter.children
[('a', True)]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
187 次 |
| 最近记录: |