当前位置: 首页>>代码示例>>Python>>正文


Python Response.content方法代码示例

本文整理汇总了Python中rest_framework.response.Response.content方法的典型用法代码示例。如果您正苦于以下问题:Python Response.content方法的具体用法?Python Response.content怎么用?Python Response.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rest_framework.response.Response的用法示例。


在下文中一共展示了Response.content方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
 def delete(self, request, obj_id, format=None):
     try:
         obj = self.queryset.objects.get(appcivist_id=obj_id)
         obj.delete()
         content = JSONRenderer().render({'text': 'The object was deleted correctly'})
         resp = Response(status=status.HTTP_200_OK)
         resp.content = content
         return resp
     except Exception as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = e
         return resp
开发者ID:joausaga,项目名称:social-ideation,代码行数:14,代码来源:views.py

示例2: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
 def get(self, request, obj_id, format=None):
     try:
         api = get_api_obj(self.initiative)
         obj_raw = getattr(api, self.api_method)(**self.api_method_params)
         obj = self.create_obj(obj_raw.id, self.initiative, obj_raw)
         serializer = self.serializer_class(obj)
         return Response(serializer.data)
     except IdeaScalyError as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = 'Error: {}'.format(e.reason)
         return resp
     except Exception as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = e
         return resp
开发者ID:rebearteta,项目名称:social-ideation,代码行数:17,代码来源:views.py

示例3: post

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
    def post(self, request, assembly, format=None):
        respmsg = "inicio"
        try:
            api = get_api_obj(assembly)

            api.ignore_admin_user = "true"
            api.social_ideation_source = request.data['source'] # indicates the name of the providerId (e.g., social_ideation_facebook)
            api.social_ideation_source_url = request.data['source_url'] # source to the original post
            api.social_ideation_user_source_url = request.data['user_url'] # link to the user
            api.social_ideation_user_source_id = request.data['user_external_id'] # email or id of the user in the source social network
            api.social_ideation_user_name = request.data['user_name'] # the name of the author in the social network
            api.assembly_id = assembly.appcivist_id
            new_obj_raw = getattr(api, self.api_method)(**self.api_method_params)
            new_obj_id = find_obj_id(new_obj_raw)
            new_obj= self.create_obj(new_obj_id, assembly, new_obj_raw)
            serializer = self.serializer_class(new_obj)
            if self.filters:
                new_obj.sync = True
                new_obj.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)

        except Exception as e:
            resp = Response(status=status.HTTP_400_BAD_REQUEST)
            resp.content = e
            return resp
开发者ID:joausaga,项目名称:social-ideation,代码行数:27,代码来源:views.py

示例4: post

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
 def post(self, request, initiative, format=None):
     try:
         api = get_api_obj(initiative)
         new_obj_raw = getattr(api, self.api_method)(**self.api_method_params)
         new_obj= self.create_obj(new_obj_raw.id, initiative, new_obj_raw)
         serializer = self.serializer_class(new_obj)
         if self.filters:
             new_obj.sync = True
             new_obj.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     except IdeaScalyError as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = 'Error: {}'.format(e.reason)
         return resp
     except Exception as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = e
         return resp
开发者ID:rebearteta,项目名称:social-ideation,代码行数:20,代码来源:views.py

示例5: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
 def get(self, request, format=None):
     try:
         assemblies = Assembly.objects.all()
         serializer = AssemblySerializer(assemblies, many=True)
         return Response(serializer.data)
     except Exception as e:
         resp = Response(status=status.HTTP_400_BAD_REQUEST)
         resp.content = e
         return resp
开发者ID:joausaga,项目名称:social-ideation,代码行数:11,代码来源:views.py

示例6: get_bitstream_data

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import content [as 别名]
def get_bitstream_data(request,id):
    """
    Return data from an especified bitstream.
    """
    try:
        bitstream_data =  Bitstream.retrieve(dspace,id,**dict(request.query_params))
        response = Response(status=status.HTTP_200_OK)
        response.content = bitstream_data
        return  response
    except Collection.DoesNotExist:
        raise Http404
开发者ID:f14c0,项目名称:conectate-dspace,代码行数:13,代码来源:views.py


注:本文中的rest_framework.response.Response.content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。