📌  相关文章
📜  django 查询多个条件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:06.441000             🧑  作者: Mango

代码示例1
from django.db.models import Q

     criterion1 = Q(UID=request.user.id) #any query you want
    criterion2 = Q(FID=user.id) #any query you want
    criterion3 = Q(FID=request.user.id) #any query you want
    criterion4 = Q(UID=user.id) #any query you want
    areTheyFriends = Friends.objects.filter(criterion1 & criterion2 | criterion3 & criterion4) # use `&` and `|` logical operators