diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index 0a34681e0..f69d4f21d 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -452,7 +452,7 @@ class Rack(NetBoxModel, DeviceWeightMixin): def get_total_weight(self): total_weight = sum(device.device_type._abs_weight for device in self.devices.exclude(device_type___abs_weight__isnull=True).prefetch_related('device_type')) - total_weight += sum(module.module_type._abs_weight for module in Module.objects.filter(device=self).exclude(module_type___abs_weight__isnull=True).prefetch_related('module_type')) + total_weight += sum(module.module_type._abs_weight for module in Module.objects.filter(device__rack=self).exclude(module_type___abs_weight__isnull=True).prefetch_related('module_type')) total_weight += self._abs_weight return total_weight diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 51e873ffa..d19ca80ae 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -186,6 +186,27 @@ {% endif %} + + {% if object.get_total_weight %} +
Rack Weight | +{{ object.weight }} kg | +
---|---|
Total Weight | +{{ object.get_total_weight }} kg | +