django - ManyToMany field, check if relation exists -


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 check if a.item in manytomany relation b.box?

it's pretty simple:

playes.objects.filter(pk=a.pk, box__pk=b.pk).exists() 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -