2👍
There’s no need for mptt if you just want to get children for a parent. That functionality is built in to Django: given an instance of Office called my_office
, you can get its children with my_office.office_set.all()
.
You probably want to give the reverse accessor a better name, which you can do by modifying the field definition:
parent = models.ForeignKey('self', null=True, related_name='children')
Now you can do my_office.children.all()
.
Source:stackexchange.com