From e18dc43aae8b06652ac04f46cf452cdfd5e199a0 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Jan 2022 09:17:15 -0500 Subject: [PATCH] Fixes #8196: Fix IndexError exception when viewing large IPv6 prefixes in UI --- docs/release-notes/version-3.1.md | 3 ++- netbox/templates/ipam/prefix.html | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 90c7520e2..c994d8305 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -9,8 +9,9 @@ ### Bug Fixes -* [#8191](https://github.com/netbox-community/netbox/issues/8191) - Fix return URL when adding IP addresses to VM interfaces * [#8187](https://github.com/netbox-community/netbox/issues/8187) - Fix rendering of tags column in object tables +* [#8191](https://github.com/netbox-community/netbox/issues/8191) - Fix return URL when adding IP addresses to VM interfaces +* [#8196](https://github.com/netbox-community/netbox/issues/8196) - Fix IndexError exception when viewing large IPv6 prefixes in UI --- diff --git a/netbox/templates/ipam/prefix.html b/netbox/templates/ipam/prefix.html index c3d3bdedd..cb62e56ae 100644 --- a/netbox/templates/ipam/prefix.html +++ b/netbox/templates/ipam/prefix.html @@ -1,4 +1,5 @@ {% extends 'ipam/prefix/base.html' %} +{% load humanize %} {% load helpers %} {% load plugins %} @@ -124,9 +125,18 @@ {{ child_ip_count }} + {% endwith %} + {% with available_count=object.get_available_ips.size %} Available IPs - {{ object.get_available_ips|length }} + + {# Use human-friendly words for counts greater than one million #} + {% if available_count > 1000000 %} + {{ available_count|intword }} + {% else %} + {{ available_count|intcomma }} + {% endif %} + {% endwith %}