mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54: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):
|
||||
queryset = Product.objects.all()
|
||||
serializer_class = ProductSerializer
|
||||
filter_backends = (filters.DjangoFilterBackend,)
|
||||
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:
|
||||
|
@ -174,6 +175,7 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha
|
|||
class ProductList(generics.ListAPIView):
|
||||
queryset = Product.objects.all()
|
||||
serializer_class = ProductSerializer
|
||||
filter_backends = (filters.DjangoFilterBackend,)
|
||||
filter_class = ProductFilter
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user