from rest_framework import filters


class SearchFilter(filters.BaseFilterBackend):
    def filter_queryset(self, request, queryset, view):
        query = request.QUERY_PARAMS.get('q', None)
        query_fields = request.QUERY_PARAMS.get('q_fields', None)
        query_fields = query_fields.split(',')
        if query:
            return queryset.search(query, query_fields)
        return queryset.all()

@@ -177,32 +177,54 @@
 .get('q', None)%0A
+        if query:%0A    
         query_fi
@@ -265,24 +265,55 @@
 _fields'
-, None)%0A
+)%0A            if query_fields:%0A        
         
@@ -351,34 +351,16 @@
 it(',')%0A
-        if query:%0A
         

fix error when no q_fields are used