Skip to content

Commit cfb5696

Browse files
authored
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
1 parent 8420af8 commit cfb5696

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

netbox/templates/dcim/device.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ <h2 class="card-header">{% trans "Dimensions" %}</h2>
325325
<td>
326326
{% if object.total_weight %}
327327
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
328+
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
328329
{% else %}
329330
{{ ''|placeholder }}
330331
{% endif %}

netbox/templates/dcim/rack.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ <h2 class="card-header">{% trans "Weight" %}</h2>
103103
<tr>
104104
<th scope="row">{% trans "Total Weight" %}</th>
105105
<td>
106-
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
107-
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
106+
{% if object.total_weight %}
107+
{{ object.total_weight|floatformat }} {% trans "Kilograms" %}
108+
({{ object.total_weight|kg_to_pounds|floatformat }} {% trans "Pounds" %})
109+
{% else %}
110+
{{ ''|placeholder }}
111+
{% endif %}
108112
</td>
109113
</tr>
110114
</table>

0 commit comments

Comments
 (0)