我正在关注 django 的教程,在模型文件(代码如下)中,在 Circle 类中,您会看到方法 contacts 返回self.user_info.contact_set.all()
。user_info 是类models.Model 的方法吗?它是何时/如何创建的?
提前致谢
class Circle(models.Model):
name = models.CharField(max_length=250)
owner = models.ForeignKey(User)
def contacts(self):
return self.user_info.contact_set.all()
def is_in_circle(self, user):
if user in self.user_info.contact_set.all():
return True
return False
class UserInfo(models.Model):
circle = models.ManyToManyField(Circle)
notes = models.TextField()