1👍
✅
You can move the hierarchy down again with the children
, so querying the ForeignKey
relation in reverse:
stores = OrgUnit.objects.filter(
type='store',
parent__parent__children__children__pk=sales_department_id
)
Here we thus query for OrgItem
s that have a parent that has a parent for which there is a child for which there is a child with as primary key the sales_department_id
.
Source:stackexchange.com