Commit 325789db by Nico Mandery

set the filter_backends class variable in the DjangoFilterBackend documentation for clearness

parent 6651432d
...@@ -149,6 +149,7 @@ If all you need is simple equality-based filtering, you can set a `filter_fields ...@@ -149,6 +149,7 @@ If all you need is simple equality-based filtering, you can set a `filter_fields
class ProductList(generics.ListAPIView): class ProductList(generics.ListAPIView):
queryset = Product.objects.all() queryset = Product.objects.all()
serializer_class = ProductSerializer serializer_class = ProductSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('category', 'in_stock') filter_fields = ('category', 'in_stock')
This will automatically create a `FilterSet` class for the given fields, and will allow you to make requests such as: This will automatically create a `FilterSet` class for the given fields, and will allow you to make requests such as:
...@@ -174,6 +175,7 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha ...@@ -174,6 +175,7 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha
class ProductList(generics.ListAPIView): class ProductList(generics.ListAPIView):
queryset = Product.objects.all() queryset = Product.objects.all()
serializer_class = ProductSerializer serializer_class = ProductSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_class = ProductFilter filter_class = ProductFilter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment