apply review comments

This commit is contained in:
Adam Dobrawy 2023-02-24 19:21:55 +01:00 committed by GitHub
parent c2921b1eca
commit a82e23c0ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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):
"""