Question: I am facing below error when try to query using 'Q' in a viewset. It will work without any issues if I use this in a management command file. My view. @permission_classes((AllowAny,)) class ClipartViewSet(viewsets.GenericViewSet): serializer_class = ClipartSerializer queryset = Clipart.objects.filter(is_active=True).all() def list(self, request, **kwargs): # Some extra logic # qs = Clipart.objects.filter(name="Apes") #This line will work without any issues qs = Clipart.objects.filter(Q(name="Apes") | Q(name="Dog")) # This line will show error print(qs) return super(ClipartViewSet, self).list(self, request, **kwargs)  Error: Internal Server Error: /api/s/configurator/cliparts backend_1 | Traceback (most recent call last): backend_1 | File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner backend_1 | response = get_response(request) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response backend_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view backend_1 | return view_func(*args, **kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/rest_framework/viewsets.py", line 125, in view backend_1 | return self.dispatch(request, *args, **kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch backend_1 | response = self.handle_exception(exc) backend_1 | File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception backend_1 | self.raise_uncaught_exception(exc) backend_1 | File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception backend_1 | raise exc backend_1 | File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch backend_1 | response = handler(request, *args, **kwargs) backend_1 | File "/backend/mycomp/apps/ecommerce/configurator/views/design_views.py", line 109, in list backend_1 | qs = Clipart.objects.filter(Q(name="Apes") | Q(name="Dog")) # This line will show error backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method backend_1 | return getattr(self.get_queryset(), name)(*args, **kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/safedelete/queryset.py", line 72, in filter backend_1 | return super(SafeDeleteQueryset, queryset).filter(*args, **kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 941, in filter backend_1 | return self._filter_or_exclude(False, args, kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude backend_1 | clone._filter_or_exclude_inplace(negate, args, kwargs) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace backend_1 | self._query.add_q(Q(*args, **kwargs)) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1391, in add_q backend_1 | clause, _ = self._add_q(q_object, self.used_aliases) backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1413, in _add_q backend_1 | split_subq=split_subq, check_filterable=check_filterable, backend_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1281, in build_filter backend_1 | arg, value = filter_expr backend_1 | TypeError: cannot unpack non-iterable MatchAll object 

Answer: Likely you implement the wrong Q, you import this with: from django.db.models import Q @permission_classes((AllowAny,)) class ClipartViewSet(viewsets.GenericViewSet): serializer_class = ClipartSerializer queryset = Clipart.objects.filter(is_active=True).all() def list(self, request, **kwargs): qs = Clipart.objects.filter(Q(name='Apes') | Q(name='Dog')) return super(ClipartViewSet, self).list(self, request, **kwargs) that being said, you can simplify the query with an __in lookup [Django-doc]: @permission_classes((AllowAny,)) class ClipartViewSet(viewsets.GenericViewSet): serializer_class = ClipartSerializer queryset = Clipart.objects.filter(is_active=True).all() def list(self, request, **kwargs): # Some extra logic qs = Clipart.objects.filter(name__in=('Apes', 'Dog')) print(qs) return super(ClipartViewSet, self).list(self, request, **kwargs)