为什么不管用? 我得到错误"Cannot filter a query once a slice has been taken." 我能做些什么来解决这个问题?
class LogbookLastViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = LogbookSerializer
permission_classes = [permissions.IsAuthenticated]
filterset_fields = ['organizationID']
def get_queryset(self):
queryset = Logbook.objects.filter(organizationID='1111').order_by('-created')[:10]
return queryset
我需要这样的东西:
SELECT * FROM logbook WHERE organizationID='1111' ORDER_BY created LIMIT 10;