From cfb5696d29f45c2abb8b24e52d537787ceb3f6f3 Mon Sep 17 00:00:00 2001 From: bctiemann Date: Tue, 24 Sep 2024 16:53:39 -0400 Subject: [PATCH] Fixes: #17126 - Respect the weight unit of the DeviceType when displaying the Device detail (#17579) * Respect the weight unit of the DeviceType when displaying the Device details * Reuse the same weight formatting construct as in rack.html, and add placeholder in rack if empty --- netbox/templates/dcim/device.html | 1 + netbox/templates/dcim/rack.html | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index b74d4b5f6..fb11e9a5c 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -325,6 +325,7 @@ {% if object.total_weight %} {{ object.total_weight|floatformat }} {% trans "Kilograms" %} + ({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %}) {% else %} {{ ''|placeholder }} {% endif %} diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index ad035dd6b..eec4d63a5 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -103,8 +103,12 @@ {% trans "Total Weight" %} - {{ object.total_weight|floatformat }} {% trans "Kilograms" %} - ({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %}) + {% if object.total_weight %} + {{ object.total_weight|floatformat }} {% trans "Kilograms" %} + ({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %}) + {% else %} + {{ ''|placeholder }} + {% endif %}