              # Filter that dynamically changes search fields
              def get_search_fields(self, view, request):
                  if request.query_params.get('title_only'):
                      return ('$title',)
                  return super(CustomSearchFilter, self).get_search_fields(view, request)
  
          class SearchListView(generics.ListAPIView):
              queryset = SearchFilterModel.objects.all()
              serializer_class = SearchFilterSerializer
              filter_backends = (CustomSearchFilter,)
 
</s> remove         return super(RelatedField, self).get_attribute(instance)
 </s> add         return super().get_attribute(instance) </s> remove         return super(RelatedField, self).run_validation(data)
 </s> add         return super().run_validation(data) </s> remove         return super(NamespaceVersioning, self).reverse(
 </s> add         return super().reverse( </s> remove         if isinstance(ordering, six.string_types):
 </s> add         if isinstance(ordering, str): </s> remove         class DummyView(object):
 </s> add         class DummyView:
                return super().get_search_fields(view, request)
              # Filter that dynamically changes search fields
              def get_search_fields(self, view, request):
                  if request.query_params.get('title_only'):
                      return ('$title',)
                return super().get_search_fields(view, request)
  
          class SearchListView(generics.ListAPIView):
              queryset = SearchFilterModel.objects.all()
              serializer_class = SearchFilterSerializer
              filter_backends = (CustomSearchFilter,)
keep keep keep keep replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
tests/test_filters.py