本文整理汇总了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)
示例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