django filter or 多条件查询

功能:django中实现多条件查询

或关系:

from django.db.models import Q
return qs.filter(Q(notice_to_group__contains='所有用户')|Q(notice_to_group__contains='段级用户'))

效果:

与关系:只需将‘|’改为‘&’

猜你喜欢

转载自www.cnblogs.com/ttzz/p/10700150.html