Replace filterset_fields with filter_fields

Was trying to use DjangoFilterBackend and it was not working until I made this change in my code
This commit is contained in:
rfb2 2019-06-06 16:30:25 +00:00 committed by GitHub
parent 9ac9c1b2ea
commit f6a90ed13b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,7 +166,7 @@ If all you need is simple equality-based filtering, you can set a `filterset_fie
queryset = Product.objects.all() queryset = Product.objects.all()
serializer_class = ProductSerializer serializer_class = ProductSerializer
filter_backends = (DjangoFilterBackend,) filter_backends = (DjangoFilterBackend,)
filterset_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: