Question: Is there a way of using the Django REST filters inside a **`GET`** function I created?

It works when I use this: 

```
class ContactListView(generics.ListAPIView):
    queryset = Profile.objects.all()
    serializer_class = UserContactListSerializer
    filter_backends = (filters.SearchFilter,)
    search_fields = ('name', 'last_name',)

```

But I want it to work in the **GET** function I created:

```
def get(self, request, pk, format=None):
    contacts = Profile.objects.get(pk=pk)
    serializer = UserContactListSerializer(contacts)
    filter_backends = (filters.SearchFilter,)
    search_fields = ('name', 'last_name',)
    return Response(serializer.data)

```

Answer: 
Inside a Get function...

Say you had a URL like `mywebsite.com/mypage/?search=[searchterm]`

then in your GET function use this:

```
def get(self, request):
    filterurl = self.request.query_params.get('search', None)
    contacts = Profile.objects.all()
    if filterurl is not None:
        contacts = Profile.objects.filter([fieldname]=filterurl)
    return Response(contacts)

```
In get function, the View is an instance. So filter\_backends is a property of this instance. You must reupdate the property of its and call "filter\_queryset" function. "filter\_backends" will be used in this function.: 

```
def get(self, request, pk, format=None):
    self.filter_backends = (filters.SearchFilter,)
    self.search_fields = ('name', 'last_name',)
    queryset = self.filter_queryset(self.get_queryset()) 
    serializer = self.get_serializer(queryset, many=True)  
    return Response(serializer.data)

```