Help with custom link #19654
-
Hello folks )) I'm trying to make custom link to IP address which is OOB address for device. I use {{ object.oob_ip.address}} but it returns address as cidr notation(192.168.12.25/24). it gives me error |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, tl;dr: |
Beta Was this translation helpful? Give feedback.
-
Works like a charm, thank you )) |
Beta Was this translation helpful? Give feedback.
Hi,
your
oob_ip
is a anipam.IPAddress
: https://github.com/netbox-community/netbox/blob/v4.3.2/netbox/dcim/models/devices.py#L561.address
is anIPAddressField
: https://github.com/netbox-community/netbox/blob/v4.3.2/netbox/ipam/models/ip.py#L720Next is some magic (which I don't understand) that converts your
IPAddressField
into anetaddr.IPNetwork
.What you're looking for is the netaddr docs: https://netaddr.readthedocs.io/en/latest/api.html#netaddr.IPNetwork.ip
tl;dr:
{{ object.oob_ip.address.ip }}