不明白在哪里调用这个方法(records_quantity),请提示。现在我收到一个错误(AttributeError:'Subject' 对象没有属性'record_set')
class Subject(models.Model):
name = models.CharField(max_length=100)
def records_quantity(self):
return self.record_set.count()
z = Subject()
z.records_quantity()
class Record(models.Model):
subject = models.ForeignKey(Subject)
record_short_description = models.CharField(max_length=100)