Update humanize_speed to support decimal Gbps/Tbps output #42

Closed
opened 2026-04-05 16:21:18 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 3/31/2026

NetBox version

v4.5.5

Feature type

Change to existing functionality

Proposed functionality

I'd like to propose updating the humanize_speed template filter so that it always formats a value using the largest appropriate unit, even when the converted result is not a whole number.

Today, the filter only promotes values to Gbps or Tbps when they divide evenly by 1000000 or 1000000000 Kbps. As a result, values such as 2500000 are rendered as 2500 Mbps instead of 2.5 Gbps, and 1600000000 is rendered as 1600 Gbps instead of 1.6 Tbps.

A practical implementation would keep the existing Kbps input, but allow decimal conversion for Mbps, Gbps, and Tbps while trimming trailing .0 for whole-number results. For example:

  • 25000002.5 Gbps
  • 5000000050 Gbps
  • 800000000800 Gbps
  • 16000000001.6 Tbps

This would also complement InterfaceSpeedChoices updates by keeping rendered interface speeds consistent across the UI.

Use case

This would make speed formatting in NetBox more consistent with the wording already used for modern interface speeds elsewhere in the application.

It also improves readability for users working with current hardware, where values such as 2.5 Gbps and 1.6 Tbps are much more natural than 2500 Mbps or 1600 Gbps.

Database changes

None.

External dependencies

None.

*Originally created by @pheus on 3/31/2026* ### NetBox version v4.5.5 ### Feature type Change to existing functionality ### Proposed functionality I'd like to propose updating the `humanize_speed` template filter so that it always formats a value using the largest appropriate unit, even when the converted result is not a whole number. Today, the filter only promotes values to Gbps or Tbps when they divide evenly by `1000000` or `1000000000` Kbps. As a result, values such as `2500000` are rendered as `2500 Mbps` instead of `2.5 Gbps`, and `1600000000` is rendered as `1600 Gbps` instead of `1.6 Tbps`. A practical implementation would keep the existing Kbps input, but allow decimal conversion for Mbps, Gbps, and Tbps while trimming trailing `.0` for whole-number results. For example: - `2500000` → `2.5 Gbps` - `50000000` → `50 Gbps` - `800000000` → `800 Gbps` - `1600000000` → `1.6 Tbps` This would also complement `InterfaceSpeedChoices` updates by keeping rendered interface speeds consistent across the UI. ### Use case This would make speed formatting in NetBox more consistent with the wording already used for modern interface speeds elsewhere in the application. It also improves readability for users working with current hardware, where values such as `2.5 Gbps` and `1.6 Tbps` are much more natural than `2500 Mbps` or `1600 Gbps`. ### Database changes None. ### External dependencies None.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#42