Repository: netbox-community/netbox
Pull request: Fixes #3872: Limit related IPs table
### Fixes: #3872

Limited the related IPs table to 50 entries (currently loads/renders all related IPs). No preference on the number; it just seemed that 50 was good enough for functionality without making the page too long.

Problem statement:
No limit on related IP addresses

### Environment
* Python version:  3.6.8
* NetBox version:  2.6.11

### Steps to Reproduce
1. Create IP address in `10/8` space, like `10.1.1.1/8`
2. Repeat step 1 numerous times with a different address each time, but the same mask
3. The list of related IPs for any of those addresses grows with every new related address

### Expected Behavior

The table of related IPs is limited (i.e. a maximum to number of related IPs are displayed). 

### Observed Behavior

The related IPs table is has no bound on its size, which slows down page loading further with every new related IP.

Hints from issue discussion:

Commit message: Fixes #3872: Limit related IPs table

Patch to review:
diff --git a/docs/release-notes/version-2.6.md b/docs/release-notes/version-2.6.md
index 3149f3cb9d9..e1715887bc4 100644
--- a/docs/release-notes/version-2.6.md
+++ b/docs/release-notes/version-2.6.md
@@ -13,6 +13,7 @@
 * [#3856](https://github.com/netbox-community/netbox/issues/3856) - Allow filtering VM interfaces by multiple MAC addresses
 * [#3857](https://github.com/netbox-community/netbox/issues/3857) - Fix group custom links rendering
 * [#3862](https://github.com/netbox-community/netbox/issues/3862) - Allow filtering device components by multiple device names
+* [#3872](https://github.com/netbox-community/netbox/issues/3872) - Limit number of related IPs
 
 ---
 
diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py
index 2cc1a0ea8df..a8a6cd846f7 100644
--- a/netbox/ipam/views.py
+++ b/netbox/ipam/views.py
@@ -676,7 +676,7 @@ def get(self, request, pk):
             address=str(ipaddress.address)
         ).filter(
             vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address)
-        )
+        )[:50]
         related_ips_table = tables.IPAddressTable(list(related_ips), orderable=False)
 
         return render(request, 'ipam/ipaddress.html', {


Code review comments:
diff_hunk: @@ -676,7 +676,7 @@ def get(self, request, pk):
             address=str(ipaddress.address)
         ).filter(
             vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address)
-        )
+        )[:50]
path: netbox/ipam/views.py
text: @user1:
Two requests:

1. Maybe use `settings.PAGINATE_COUNT` instead of hard-coding this value (it defaults to 50 anyway). This variable should be directly accessible from within the template.

2. Check whether the total number of records exceeds the displayed length. If so, include a link to the filtered IP addresses list for convenience.

@author:
Done and done.