MCPcopy Create free account
hub / github.com/1Panel-dev/MaxKB / ObjectField

Class ObjectField

apps/common/field/common.py:15–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15class ObjectField(serializers.Field):
16 def __init__(self, model_type_list, **kwargs):
17 self.model_type_list = model_type_list
18 super().__init__(**kwargs)
19
20 def to_internal_value(self, data):
21 for model_type in self.model_type_list:
22 if isinstance(data, model_type):
23 return data
24 self.fail(_('Message type error'), value=data)
25
26 def to_representation(self, value):
27 return value
28
29
30class InstanceField(serializers.Field):

Callers 4

InputFieldClass · 0.90
InputFieldClass · 0.90
InputFieldClass · 0.90
InputFieldClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected