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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -