我的models.py
:
class Section(models.Model):
title = models.CharField(max_length=50)
class Lesson1(models.Model):
section = models.ForeignKey(Section)
title = models.CharField(max_length=50)
...
sort_index = models.IntegerField()
class Lesson2(models.Model):
section = models.ForeignKey(Section)
title = models.CharField(max_length=50)
....
sort_index = models.IntegerField()
我需要将它们混合显示,如下所示:
section title:
-lesson1 title
-lesson2 title
-lesson1 title
next section title:
-lesson2 title
-lesson2 title
-lesson1 title
有一个很好的方法吗?