class Player(models.Model):
item = models.ForeignKey(Test)
box = models.ManyToManyField(Test)
的观点:
a = Player.object.get(id=1)
b = Player.objects.get(id=5)
如何检查a.item
是否与b.box
处于ManyToMany关系?
答案 0 :(得分:3)
非常简单:
Playes.objects.filter(pk=a.pk, box__pk=b.pk).exists()