From a82e23c0ff31827094d442a9f21c35c5e75bad7f Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Fri, 24 Feb 2023 19:21:55 +0100 Subject: [PATCH] apply review comments --- docs/api-guide/filtering.md | 2 +- rest_framework/filters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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): """