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:
toran billups 2013-02-10 13:24:39 -06:00
parent 29136ef2c6
commit 4af51b402f

View File

@ -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:
@ -175,4 +175,4 @@ For example:
[cite]: https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters [cite]: https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters
[django-filter]: https://github.com/alex/django-filter [django-filter]: https://github.com/alex/django-filter
[django-filter-docs]: https://django-filter.readthedocs.org/en/latest/index.html [django-filter-docs]: https://django-filter.readthedocs.org/en/latest/index.html
[nullbooleanselect]: https://github.com/django/django/blob/master/django/forms/widgets.py [nullbooleanselect]: https://github.com/django/django/blob/master/django/forms/widgets.py