Combing two querries using Q objects in Django?

I have defined following view:

class SearchListView(ListView):
    template_name = "movies/search_list.html"

    # overwriting the get_queryset function to customize the queryset
    def get_queryset(self) -> list:
        query = self.request.GET.get("q")
        if query:
            movies = list(
                    lambda x: unidecode(query.lower()) in unidecode(x.title).lower(),
            actors = list(
                    lambda x: unidecode(query.lower()) in unidecode(,
            # use the chain function to combine the querysets
            return list(chain(movies, actors))
            # return an empty list if no query is provided
            return []

And it is working as I want it to, however I have been trying to combine the querries into one querry using Q objects, but did not succeed. Do you think it's even possible in this case?

Back to Top