这是我的查询,
users = User.objects.all() # contains all users
extra_users = Models.objects.filter(user=request.user) # contains few users related to request.user through ManyToMany relationship
Hoe可以从用户中排除extra_users吗?
答案 0 :(得分:0)
尝试:
extra_users = Models.objects.filter(user=request.user)
users = Users.objects.exclude(pk__in=extra_users)
答案 1 :(得分:0)
Users.objects.all().exclude(user=request.user)