Reputation: 33
class Player(models.Model):
item = models.ForeignKey(Test)
box = models.ManyToManyField(Test)
views:
a = Player.object.get(id=1)
b = Player.objects.get(id=5)
How to check if a.item
is in ManyToMany relation with b.box
?
Upvotes: 3
Views: 4450
Reputation: 10135
It's pretty simple:
Playes.objects.filter(pk=a.pk, box__pk=b.pk).exists()
Upvotes: 3