class StockFilter(django_filters.rest_framework.FilterSet): #搜索名称要与前端搜索名称一致 tradeName = django_filters.CharFilter(field_name='trade_name', lookup_expr='icontains') tradeCode = django_filters.CharFilter(field_name='trade_code', lookup_expr='icontains') """ 基础信息 """ class StockModelViewSet(CustomModelViewSet): queryset = STOCK.objects.all().order_by('id') serializer_class = StockModelSerializer # filter_fields = ['id'] filterset_class = StockFilter
##查询
base = BASE.objects.filter(id=2) return SuccessResponse(data=base.values())
标签:name,模型,查询,class,filters,django,id From: https://www.cnblogs.com/yyyyyyyyx/p/17702816.html