1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Extend to support the assignment of multiple objects per field

This commit is contained in:
jeremystretch
2022-01-05 17:05:54 -05:00
parent 954d81147e
commit 271b7adeb8
5 changed files with 82 additions and 10 deletions

View File

@ -53,6 +53,9 @@ class CustomFieldsDataField(Field):
if value is not None and cf.type == CustomFieldTypeChoices.TYPE_OBJECT:
serializer = get_serializer_for_model(cf.object_type.model_class(), prefix='Nested')
value = serializer(value, context=self.parent.context).data
elif value is not None and cf.type == CustomFieldTypeChoices.TYPE_MULTIOBJECT:
serializer = get_serializer_for_model(cf.object_type.model_class(), prefix='Nested')
value = serializer(value, many=True, context=self.parent.context).data
data[cf.name] = value
return data