Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filters = Q(is_default = False)
- # Build the excludes and filters dynamically
- if cut:
- filters = filters & Q(mailbagstats__num_letters2__gt = int(cut) )
- >>> filter = Q(a=True)
- >>> filter = filter & Q(b=True)
- >>> filter.children
- [('a', True), ('b', True)]
- >>> filter.children.pop()
- ('b', True)
- >>> filter.children
- [('a', True)]
- filters = []
- filters.append(Q(is_default = False))
- # Build the excludes and filters dynamically
- if cut:
- filters.append(Q(mailbagstats__num_letters2__gt = int(cut)))
- # I want to pop the last one
- filters.pop()
- # build the filter before making the query
- # Note that this call will remove an element from the filters list
- filters_for_query = reduce(lambda a, x: a & x, filters, filters.pop())
- Model.objects.filter(filters_for_query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement