Reputation: 824
If I have a structure with one level of child objects I can easily get them through parent.child_set.all()
However I want to get childs of childs as objects from database. Must I really tinker away with recursion or is there some simpler django queryset method to get all child-related objects?
Upvotes: 1
Views: 1578
Reputation: 497
You can always use filter
rather than using child_set
. Try to filter on the Model with the foreign key
attribute.
Upvotes: -1
Reputation: 1298
Something in "other directions" should work, so it would be e.g.:
SecondChild.objects.filter(first_child__parent=some_parent)
Upvotes: 3