mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-10 01:28:16 -06:00
14606 add id to GenericObjectSerializer
This commit is contained in:
parent
e0f138dea2
commit
3b767fd7d3
@ -16,6 +16,7 @@ class GenericObjectSerializer(serializers.Serializer):
|
||||
"""
|
||||
Minimal representation of some generic object identified by ContentType and PK.
|
||||
"""
|
||||
id = serializers.IntegerField()
|
||||
object_type = ContentTypeField(
|
||||
queryset=ContentType.objects.all()
|
||||
)
|
||||
@ -30,6 +31,7 @@ class GenericObjectSerializer(serializers.Serializer):
|
||||
def to_representation(self, instance):
|
||||
object_type = ObjectType.objects.get_for_model(instance)
|
||||
data = {
|
||||
'id': instance.pk,
|
||||
'object_type': object_type_identifier(object_type),
|
||||
'object_id': instance.pk,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user