1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#8096: Include only first assigned IP in FHRPGroup string representation

This commit is contained in:
jeremystretch
2021-12-18 14:19:57 -05:00
parent b00eeb86ea
commit 2db82a73a5

View File

@ -58,13 +58,11 @@ class FHRPGroup(PrimaryModel):
def __str__(self): def __str__(self):
name = f'{self.get_protocol_display()}: {self.group_id}' name = f'{self.get_protocol_display()}: {self.group_id}'
# Append the list of assigned IP addresses to serve as an additional identifier # Append the first assigned IP addresses (if any) to serve as an additional identifier
if self.pk: if self.pk:
ip_addresses = [ ip_address = self.ip_addresses.first()
str(ip.address) for ip in self.ip_addresses.all() if ip_address:
] return f"{name} ({ip_address})"
if ip_addresses:
return f"{name} ({', '.join(ip_addresses)})"
return name return name