DeviceSerializer should use a proper serializer for its parent device #1123

Closed
opened 2025-12-29 16:29:13 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Jul 25, 2017).

Issue type: Bug Report

Python version: 2.7.6
NetBox version: 2.0.10

The DeviceSerializer currently uses a custom SerializerMethodField to return information about a device's parent device:

    def get_parent_device(self, obj):
        try:
            device_bay = obj.parent_bay
        except DeviceBay.DoesNotExist:
            return None
        return {
            'id': device_bay.device.pk,
            'name': device_bay.device.name,
            'device_bay': {
                'id': device_bay.pk,
                'name': device_bay.name,
            }
        }

This should be replaced with a proper serializer and include a URL to the related object.

Originally created by @jeremystretch on GitHub (Jul 25, 2017). ### Issue type: Bug Report **Python version:** 2.7.6 **NetBox version:** 2.0.10 The DeviceSerializer currently uses a custom SerializerMethodField to return information about a device's parent device: ``` def get_parent_device(self, obj): try: device_bay = obj.parent_bay except DeviceBay.DoesNotExist: return None return { 'id': device_bay.device.pk, 'name': device_bay.device.name, 'device_bay': { 'id': device_bay.pk, 'name': device_bay.name, } } ``` This should be replaced with a proper serializer and include a URL to the related object.
adam added the type: bug label 2025-12-29 16:29:13 +01:00
adam closed this issue 2025-12-29 16:29:14 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1123