Exemplo n.º 1
0
Arquivo: rest.py Projeto: gzqichang/wa
 def to_representation(self, instance):
     data = super(RelationSerializer, self).to_representation(instance)
     # 序列化 target
     self.relations = self._context['view'].relations
     serializer_class = get_callable(self.relations.get('target_serializer_class'))
     if serializer_class:
         data['target'] = serialize_attr(self, serializer_class, instance.target)
     return data
Exemplo n.º 2
0
Arquivo: rest.py Projeto: gzqichang/wa
 def get_actor(self, obj):
     return serialize_attr(self, self.actor_serializer_class, obj.actor)