动态范围滤波器无法正常工作

时间:2018-06-08 07:58:03

标签: python django dynamic filter range

对于以下代码,当我选择1-5之间的范围时,输出也包含6-10之间的范围。请帮忙

qu=dict(request.GET)

    # result=Package.objects.all()

    for key,value in qu.items():
        qu[key]={'attri':value}
    dict3={n:{**qu[n],**d[n]} for n in qu }
    print(dict3)
    result=Package.objects.all()
    print("\n{}\n".format(result))


    for key, value in dict3.items():
        vls = value['attri']
        if value['op'] == 'range':
            vls = [ literal_eval(vl) for vl in vls ]
            # print(vls)
            # print()
            cond_name = 'attributes__{}__{}'.format(key, value['op'])
            conditions = reduce(or_, [Q(**{cond_name: vl}) for vl in vls], Q())

0 个答案:

没有答案