mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Merge pull request #3017 from nmandery/feature/set-filter_backends-in-api-docs
Set the filter_backends class variable in the DjangoFilterBackend docs
This commit is contained in:
commit
2749b12eaf
|
@ -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