class Book(models.Model):
# fields
class Chapter(models.Model):
book = models.ForeignKey(Book)
class Page(models.Model):
chapter = models.ForeignKey(Chapter)
我想要 A 书的所有页面,可能不需要循环每一章来获取页面。
book = Book.objects.get(pk=1)
pages = book.chapter_set.page_set #?!?