5.10.drf的过滤
通过属性过滤
class GoodsCategoryViewSet(ListModelMixin, GenericViewSet):
"""
获取商品类型列表
"""
queryset = GoodsCategory.objects.all()
...通过函数过滤
class GoodsCategoryViewSet(ListModelMixin, GenericViewSet):
"""
获取商品类型列表
"""
queryset = GoodsCategory.objects.all()
...
def get_queryset(self):
return GoodsCategory.objects.filter(category_type__gt=1)django-filter
自定义django-filter
Last updated