I have something like this in my 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()
And I need to display them mixed, like this:
section title:
-lesson1 title
-lesson2 title
-lesson1 title
next section title:
-lesson2 title
-lesson2 title
-lesson1 title
Is there a nice way to do this?
sort_index? If so what happens if the lesson1 and lesson2 for a particular section have the samesort_indexvalue, who gets precendence?Lessonbase model and have the other models inherit from this. You could use something like django-polymorphic.readthedocs.org/en/latest to implement the polymorphic behaviour of the lessons... The other possibilty would be using a generic foreign key...