[Answered ]-Fetching related parent objects in a chain in Django

2👍

What you have there is a tree structure, with the CEO at the top. Those aren’t easy to represent in databases generally. Luckily there is a nice algorithm that will do it for you, MPTT, and a great Django implementation in django-mptt. It will involve some changes to your data, but using that will allow you to get all ancestors of an employee – or all descendants – in one go.

Leave a comment