mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
set the filter_backends class variable in the DjangoFilterBackend documentation for clearness
This commit is contained in:
parent
6651432d59
commit
325789db95
|
@ -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
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user