diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index afb44ea3f..65b745a38 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -196,7 +196,7 @@ When in use, the browsable API will include a `SearchFilter` control: ![Search Filter](../img/search-filter.png) -The `SearchFilter` class will only be applied if the view or `SearchFilter` class itself has a `search_fields` attribute set. The `search_fields` attribute should be a list of names of text type fields on the model, such as `CharField` or `TextField`. +The `SearchFilter` class will only be applied if `SearchFilter` class itself or the view has a `search_fields` attribute set. The `search_fields` attribute should be a list of names of text type fields on the model, such as `CharField` or `TextField`. from rest_framework import filters diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 6397abdfe..52258f1d2 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -56,7 +56,7 @@ class SearchFilter(BaseFilterBackend): always passed to this method. Sub-classes can override this method to dynamically change the search fields based on request content. """ - return getattr(view, 'search_fields', getattr(self, 'search_fields')) + return getattr(self, 'search_fields', getattr(view, 'search_fields')) def get_search_terms(self, request): """