Skip to content
Discussion options

You must be logged in to vote

Thats because parent_device is a nested serializer:

@swagger_serializer_method(serializer_or_field=NestedDeviceSerializer)
def get_parent_device(self, obj):
try:
device_bay = obj.parent_bay
except DeviceBay.DoesNotExist:
return None
context = {'request': self.context['request']}
data = NestedDeviceSerializer(instance=device_bay.device, context=context).data
data['device_bay'] = NestedDeviceBaySerializer(instance=device_bay, context=context).data
return data

I don't think it was ever intended to get written to however.

You need to find the device_bay id and then …

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@jsenecal
Comment options

@ViktorTelecom
Comment options

Answer selected by ViktorTelecom
Comment options

You must be logged in to vote
1 reply
@ViktorTelecom
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants