user_info方法来自哪里

时间:2013-11-13 20:54:56

标签: django django-models

我正在关注django的教程并在模型文件中(代码如下),在Circle类中,您将看到方法联系人返回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()

0 个答案:

没有答案