Skip to content

Commit

Permalink
Fixes: #11478 - Alters interface serializers get_display to include d…
Browse files Browse the repository at this point in the history
…evice to string representation.
  • Loading branch information
DanSheps committed Jul 11, 2023
1 parent 0f0cf68 commit b63f20c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netbox/dcim/api/nested_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ class Meta:
model = models.Interface
fields = ['id', 'url', 'display', 'device', 'name', 'cable', '_occupied']

def get_display(self, obj):
return f"{obj.name} ({obj.device})"


class NestedRearPortSerializer(WritableNestedSerializer):
device = NestedDeviceSerializer(read_only=True)
Expand Down
3 changes: 3 additions & 0 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@ class Meta:
'last_updated', 'count_ipaddresses', 'count_fhrp_groups', '_occupied',
]

def get_display(self, obj):
return f"{obj.name} ({obj.device})"

def validate(self, data):

# Validate many-to-many VLAN assignments
Expand Down

0 comments on commit b63f20c

Please sign in to comment.