mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
corrected an error in the filtering api-guide
I found the latest version of django-filter requires a list of field attributes instead of a tuple. This might help others who are looking over the docs as I got an error trying to implement this using the wrong data structure "django-filter Meta.fields contains a field that isn't defined on this FilterSet ..."
This commit is contained in:
parent
29136ef2c6
commit
4af51b402f
|
@ -102,7 +102,7 @@ If all you need is simple equality-based filtering, you can set a `filter_fields
|
||||||
class ProductList(generics.ListAPIView):
|
class ProductList(generics.ListAPIView):
|
||||||
model = Product
|
model = Product
|
||||||
serializer_class = ProductSerializer
|
serializer_class = ProductSerializer
|
||||||
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:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user