我如何使用list_route方法中的分页?我有看法:
class view(mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
viewsets.GenericViewSet):
...
@list_route(methods=['get'])
def some_method(self, request, **kwargs):
queryset = Model.objects.all()
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
Run Code Online (Sandbox Code Playgroud) 我按排名尝试订单表,但是具有位置值的行 - 必须根据位置字段中的值具有位置.没有额外的表格,视图等可以做到这一点吗?
我有这样的表:
rank | position | name
999 | 10 | txt1
200 | 4 | txt2
32 | 1 | txt3
1200 | 2 | txt4
123 | null | txt5
234 | null | txt6
567 | null | txt7
234 | null | txt8
432 | null | txt9
877 | null | txt10
Run Code Online (Sandbox Code Playgroud)
期望的输出必须如下所示:
rank | position | name
32 | 1 | txt3
1200 | 2 | txt4
877 | null | txt10 …Run Code Online (Sandbox Code Playgroud)