drf的倒序操作
用第三方的库实现
from django_filters.rest_framework import filters, FilterSet, OrderingFilter from .models import PvUv __all__ = ['EsPvUvFilter'] class EsPvUvFilter(FilterSet): createDate = filters.DateFilter(field_name='createDate', lookup_expr='exact') es_index = filters.CharFilter(field_name='es_index__name', lookup_expr='exact') sort = OrderingFilter(fields=('createDate', 'id')) class Meta: model = PvUv fields = ['createDate', 'es_index']
前端请求例子
export function getPvUv(data) { return request({ url: '/statement/panel/EsPvUv/?sort=-id', method: 'get', params: data }) }