Search Bar returns SQL on the GET query

My view:

class SearchView(generic.ListView):
    paginate_by = 15
    template_name = 'search.html'

    def get_queryset(self):
        query = self.request.GET.get('q', '')
        if query:
            object_list = Post.objects.filter(
            object_list = []
        return object_list

My template:

 <p>You searched for {{ object_list.query }}</p>

Shows SQL…

I want it to show only “TEST” after I use the search bar.

For contrast in a function based view it works:

def search(request):
    if request.method == 'GET':
        searched = request.GET['q']

        recipes = Post.objects.filter(title__contains=searched)

        return render(request, 'search.html', {'searched':searched, 'recipes':recipes})
        return render(request, 'search.html', {})

object_list is a queryset.

So, object_list.query is the representation of the query used to generate that queryset.

If you’re looking for the variable passed in from the GET, you would refer to it as only query. (Note, you’ll need to add that to the context to make it available to the template, in the same manner that you are passing searched into the context of the call to render in the FBV-version in your code.)