From 5bdc44bc894b1b1c606d59a48434133ea1c95f98 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Tue, 10 Jan 2023 09:22:05 +0100 Subject: [PATCH] Add search_fields attribute to SearchFilter --- rest_framework/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 1ffd9edc0..aaa476005 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -48,6 +48,7 @@ class SearchFilter(BaseFilterBackend): } search_title = _('Search') search_description = _('A search term.') + search_fields = None def get_search_fields(self, view, request): """ @@ -55,7 +56,7 @@ class SearchFilter(BaseFilterBackend): 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', None) + return getattr(view, 'search_fields', getattr(self, 'search_fields')) def get_search_terms(self, request): """