1.views 文件中
from rest_framework.filters import OrderingFilter
class ModuleView(mixins.ListModelMixin, mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, GenericViewSet): queryset = models.Module.objects.filter(is_delete=False) serializer_class = serializers.ModuleSerializer pagination_class = MyPageNumberPagination filter_backends = [DjangoFilterBackend, OrderingFilter] #重点OrderingFilter filter_class = ModuleFilterSet ordering_fields = ['createTime'] #重点