1👍
✅
try this
return self.get_queryset()
.filter(is_active = True)
.aggregate(total_inventory=Sum('inventory__quantity'))
.get('total_inventory')
Source:stackexchange.com