def stars_keyword_list_detail(request, keyword_id):
"""
Returns stars list detail for keyword id.
---
response_serializer: stars.serializers.StarTopEmployeeLists
responseMessages:
- code: 401
message: Unauthorized. Authentication credentials were not provided. Invalid token.
- code: 403
message: Forbidden, authentication credentials were not provided
- code: 404
message: Not found
"""
if request.method == 'GET':
keyword = get_object_or_404(Keyword, pk=keyword_id)
stars = Star.objects.filter(keyword=keyword).values(
'to_user__pk',
'to_user__username',
'to_user__first_name',
'to_user__last_name',
'to_user__level',
'to_user__avatar').annotate(num_stars=Count('keyword')).order_by('-num_stars')
paginator = PageNumberPagination()
results = paginator.paginate_queryset(stars, request)
serializer = StarTopEmployeeLists(results, many=True)
return paginator.get_paginated_response(serializer.data)
评论列表
文章目录