"Devices" list shows only one primary IP if device has both primary v4/v6 #681

Closed
opened 2025-12-29 16:24:42 +01:00 by adam · 4 comments
Owner

Originally created by @candlerb on GitHub (Jan 31, 2017).

  • Create a device with one interface
  • Add a IPv4 and IPv6 to that interface, marking them both as "Primary"
  • Search for it by name
  • In the resulting table, the right hand column is "IP Address" but it shows only one address (I am seeing the IPv6 one)

I think that ideally it would show the primary IPv4 and IPv6 addresses one below the other in the same table column.

Originally created by @candlerb on GitHub (Jan 31, 2017). * Create a device with one interface * Add a IPv4 and IPv6 to that interface, marking them both as "Primary" * Search for it by name * In the resulting table, the right hand column is "IP Address" but it shows only one address (I am seeing the IPv6 one) I think that ideally it would show the primary IPv4 and IPv6 addresses one below the other in the same table column.
adam added the type: feature label 2025-12-29 16:24:42 +01:00
adam closed this issue 2025-12-29 16:24:42 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 31, 2017):

The Device model has a convenience property named primary_ip which returns either the primary v6 IP or the primary v4 IP (or None):

    @property
    def primary_ip(self):
        if settings.PREFER_IPV4 and self.primary_ip4:
            return self.primary_ip4
        elif self.primary_ip6:
            return self.primary_ip6
        elif self.primary_ip4:
            return self.primary_ip4
        else:
            return None

We can include both IPs, but doing so would remove the option to enable sorting devices by IP address. (This isn't currently available, but could be.)

@jeremystretch commented on GitHub (Jan 31, 2017): The `Device` model has a convenience property named `primary_ip` which returns either the primary v6 IP or the primary v4 IP (or `None`): ``` @property def primary_ip(self): if settings.PREFER_IPV4 and self.primary_ip4: return self.primary_ip4 elif self.primary_ip6: return self.primary_ip6 elif self.primary_ip4: return self.primary_ip4 else: return None ``` We can include both IPs, but doing so would remove the option to enable sorting devices by IP address. (This isn't currently available, but could be.)
Author
Owner

@candlerb commented on GitHub (Jan 31, 2017):

Idea: have a new property which returns IPv6<br/>IPv4 or IPv4<br/>IPv6 (depending on the PREFER_IPV4 setting). Then could you sort on that?

Sorry - ignore stupid idea. Addresses don't sort as strings.

@candlerb commented on GitHub (Jan 31, 2017): ~~Idea: have a new property which returns `IPv6<br/>IPv4` or `IPv4<br/>IPv6` (depending on the PREFER_IPV4 setting). Then could you sort on that?~~ Sorry - ignore stupid idea. Addresses don't sort as strings.
Author
Owner

@candlerb commented on GitHub (Jan 31, 2017):

Personally I'm fine with not being able to sort in this view. However:

Simple solution: have separate columns for primary v4 and primary v6.

The downside is that people may need to buy larger monitors - annoying for people who aren't using v6. But I think there's a separate ticket for being able to customise the columns displayed.

Complex solution: have a property which returns a compound value like [ipv4, ipv6] which is sortable, and can be rendered appropriately.

@candlerb commented on GitHub (Jan 31, 2017): Personally I'm fine with not being able to sort in this view. However: Simple solution: have separate columns for primary v4 and primary v6. The downside is that people may need to buy larger monitors - annoying for people who aren't using v6. But I think there's a separate ticket for being able to customise the columns displayed. Complex solution: have a property which returns a compound value like `[ipv4, ipv6]` which is sortable, and can be rendered appropriately.
Author
Owner

@jeremystretch commented on GitHub (Jan 31, 2017):

Eh, IMO sorting devices by primary IP isn't needed. One can always do that via the IP address list if needed anyway. I think listing the IPv6 and/or IPv4 primaries in the same column makes sense.

@jeremystretch commented on GitHub (Jan 31, 2017): Eh, IMO sorting devices by primary IP isn't needed. One can always do that via the IP address list if needed anyway. I think listing the IPv6 and/or IPv4 primaries in the same column makes sense.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#681