(using my nomenclature).
class Library(models.Model)
branch=models.CharField(max_length=100)
class Book(models.Model)
libraryid=models.ForeignKey(Library,related_name="books")
class Chapter(models.Model)
bookid=models.ForeignKey(Book,related_name="chapters")
I can get a library object:
l=Library.objects.filter(branch="Covent Garden")
and then get a query set of all the books in Covent Garden
b=l.books.all()
How do I get a query set of all the chapters (in all the books) in the
Covent Garden library?
then then if I added
class Paragraph(models.Model)
chapterid=models.ForeignKey(Chapter,related_name="paragraphs")
How would I get a query set of all the paragraphs (in all the chapters
in all the books) in the Covent Garden library?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment