I am trying to split my query based on a space `" "`. example `first_name` `last_name` however if I try to check for spaces in my seach I get the error

> 
> argument of type 'NoneType' is not iterable 
> 
> 
> 

```
if ' ' in query: #This is where is the error is generated

```

Trying to fix the above issue. Below is the entire code

```
class QList(SelectRelatedMixin, ListView):
    model = Question

    def get_queryset(self):
        queryset = super(QList, self).get_queryset().order_by('-created_at')
        query = self.request.GET.get('q')

        if ' ' in query:
            query = query.split()
            queryset = queryset.filter(
                chain(User.objects.filter(first_name__icontains=query[0], last_name__icontains=query[1]),
                      User.objects.filter(first_name__icontains=query[1], last_name__icontains=query[0])))

            return queryset
        else:
            queryset = queryset.filter(
                Q(user__username__iexact=query) |
                Q(user__first_name__iexact=query) |
                Q(user__last_name__iexact=query)

                )
        return queryset

```

Can anyone suggest a workaround