方式一:
q=Q() q.connection="or" q.children.append(("pk",1)) q.children.append(("user_id",1)) q.children.append(("room_id",1)) Book.objects.filter(q)
方式二:
Book.objects.filter(Q(pk=1)|Q(user_id=1)|Q(room_id=1))
方式一:
q=Q() q.connection="or" q.children.append(("pk",1)) q.children.append(("user_id",1)) q.children.append(("room_id",1)) Book.objects.filter(q)
方式二:
Book.objects.filter(Q(pk=1)|Q(user_id=1)|Q(room_id=1))