class Course(models.Model):
def is_active(self):
return self.enroll_set.count()>0
class CourseEvent(models.Model):
course = models.ForeignKey(Course)
我想找到所有Events
只指向活动课程的内容。就像是:
events = CourseEvent.objects.filter(course.is_active=True)
谢谢你