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


Python Response.status方法代码示例

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


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

示例1: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import status [as 别名]
    def get(self, request, offset=0, limit=10, orderBy='id', order='asc', filterOn=None, filterValue=None,format=None):
        if offset is None:
            offset = 0
        if limit is None:
            limit = 10
        if orderBy == None:
            orderBy = 'id'
        if order == 'desc':
            orderBy = '-' + orderBy

        try:
            if filterOn is None or filterValue is None:
                users = Users.objects.all().order_by(orderBy)[offset:limit]
                count = Users.objects.all()[offset:limit].count()
            else:    
                users = Users.objects.all().filter(**{ filterOn: filterValue }).order_by(orderBy)[offset:limit]
                count = Users.objects.all().filter(**{ filterOn: filterValue })[offset:limit].count()
            total_count = Users.objects.count()
            serializer = UserDetailListViewSerializer(users, many=True)
            response = Response()
            response['count'] = count
            response['total_count'] = total_count
            response.data = serializer.data
            response.status = status.HTTP_200_OK 
            return response
        except Users.DoesNotExist:
            return Response(status=status.HTTP_400_BAD_REQUEST) 
开发者ID:givery-technology,项目名称:api-challenge-django,代码行数:29,代码来源:views.py

示例2: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import status [as 别名]
 def get(self, request, *args, **kwargs):
     network = []
     for entity in Entity.objects.filter(match__isnull=False):
         entry = {
             'from': entity.user_profile.user.pk,
             'to': entity.match.user_profile.user.pk
         }
         network.append(entry)
     response = Response(network)
     response.status = 200
     return response
开发者ID:TeoTN,项目名称:ScopeIT,代码行数:13,代码来源:views.py


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