Django check if object in ManyToMany field

前端 未结 1 1202
别跟我提以往
别跟我提以往 2020-12-28 12:43

I have quite a simple problem to solve. I have Partner model which has >= 0 Users associated with it:

class Partner(models.Model):
    name = models.CharFi         


        
相关标签:
1条回答
  • 2020-12-28 13:20
    if user.partner_set.filter(slug=requested_slug).exists():
         # do some private stuff
    
    0 讨论(0)
提交回复
热议问题