混合相关对象django

时间:2014-02-19 14:57:50

标签: python django

我的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

有一个很好的方法吗?

0 个答案:

没有答案