conditional_expressions.py 文件源码

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

项目:djangolab 作者: DhiaTN 项目源码 文件源码
def registrations_matching_complex_pattern():
    """
    Q objects generation can be also automated
    """
    predicate_list = [
        ('event__name__endswith', 'python'),
        ('member__community__name__contains', 'python')
    ]
    q_object_list = [Q(predicate) for predicate in predicate_list]
    pattern = reduce(OR, q_object_list)
    registration_number = Registration.objects.filter(pattern).count()
    print("{nbr} match the pattern 'python'".format(nbr=registration_number))


## When(), Case() expressions
##############################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号