class PagerSerialiser(serializers.ModelSerializer): # 定义返回的字段名称 game = serializers.SerializerMethodField('get_game') class Meta: model = models.Order fields = ['id','game'] # obj就是models对象 在函数内写数据结构改变 最后需要返回 def get_game(self,obj): game_name = models.Games.objects.get(uuid=obj.game_uuid).name return game_name