Asserting for presence of added objects in Django ManyToMany relation

后端 未结 2 718
时光说笑
时光说笑 2021-01-27 04:43

I have the following model;

class Station(models.Model):
    name = models.CharField(max_length=50)
    address = models.TextField(default=\'\')
    owner = mode         


        
2条回答
  •  无人共我
    2021-01-27 04:53

    station.members is a Manager, i.e. it is the accessor for queries on the related users. You need to actually perform a query: in this case, station.members.all().

提交回复
热议问题