
Q:创建或条件
&(and)
|(or)
~(not)操作符
from django.db.models import Qobj = user.objectsif xx_list:obj = obj.filter(Q(r1__in=xx_list) | Q(r2__in=xx_list))if xx_list:obj = obj.filter(Q(r1__in=xx_list) & Q(r2__in=xx_list))if xx_list:obj = obj.filter(~Q(r1__in=xx_list) ~ Q(r2__in=xx_list))data = obj.values()return list(data)