阅读背景:

如何定义返回相关对象的方法

来源:互联网 

I have two models:

我有两个型号:

class Profile(models.Model):
    user = models.OneToOneField(User, null=True)
    address = models.CharField(max_length=500)

    def pets(self):
        return Pet.objects.filter(owner=self.id)

class Pet(models.Model):
    owner = models.ForeignKey(Profile)
    name = models.CharField(max_length=150)
class Profile(mo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: