title: Django rest framework filtering "NoneType is not iterable"
body: <p>I am trying to build a simple REST read only API with django and specifically, django rest framework. The goal here is to allow filtering with two simple fields : name and config.</p>
  
  <p>When running that code, I get a "'NoneType' object is not iterable" error. 
  I am wondering if I should put the line : </p>
  
  <pre><code>queryset = Component.objects.all()
  </code></pre>
  
  <p>Since the method get_queryset overrides that after. But I don't put that line, I get a "<code>base_name</code> argument not specified, and could not automatically determine the name from the viewset, as it does not have a <code>.queryset</code> attribute." error.</p>
  
  <p>Here is my Model : </p>
  
  <pre><code>class Component(models.Model):
      name = models.CharField(max_length=200)
  
      def configs(self):
          return Config.objects.filter(exchange=self)
  
      def __unicode__(self):
          return self.name
  
  class Config(models.Model):
      name = models.CharField(max_length=200)
      exchange = models.ForeignKey(Component)
  
      def sections(self):
          return Section.objects.filter(config=self)
  
      def __unicode__(self):
          return self.name
  
  class Section(models.Model):
      name = models.CharField(max_length=200)
      config = models.ForeignKey(Config)
  
      def pairs(self):
          return KeyValues.objects.filter(section=self)
  
      def __unicode__(self):
          return self.name
  
  class KeyValues(models.Model):
      key = models.CharField(max_length=200)
      value = models.CharField(max_length=999)
      section = models.ForeignKey(Section)
  </code></pre>
  
  <p>Here is my ViewSet : </p>
  
  <pre><code>class ComponentViewSet(viewsets.ReadOnlyModelViewSet):
      model = Component
      queryset = Component.objects.all()
      serializer_class = ComponentSerializer
      renderer_classes = (JSONRenderer, )
  
      def get_queryset(self):
          queryset = Component.objects.all()
          name_component = self.request.query_params.get('name', None)
          name_cfg = self.request.query_params.get('name_cfg', None)
  
          if name_component is not None and name_cfg is not None:
              queryset = Config.objects.filter(exchange=Component.objects.filter(name=name_component), name=name_cfg)
  
          return queryset
  </code></pre>
  
  <p>Could please tell me what I am doing wrong here ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is the full stacktrace:</p>
  
  <pre><code>TypeError at /components/
  
  'NoneType' object is not iterable
  
  Request Method:     GET
  Request URL:    http://127.0.0.1:8000/components/?name=Coinbase
  Django Version:     1.8.3
  Exception Type:     TypeError
  Exception Value:    
  
  'NoneType' object is not iterable
  
  Exception Location:     /usr/local/lib/python2.7/dist-packages/rest_framework/filters.py in filter_queryset, line 107
  Python Executable:  /usr/bin/python2.7
  Python Version:     2.7.9
  Python Path:    
  
  ['/home/flavio/git/web_prncpss',
   '/home/flavio/Downloads/pycharm-4.5.3/helpers/pydev',
   '/usr/local/lib/python2.7/dist-packages/pusherclient-0.3.0-py2.7.egg',
   '/usr/lib/python2.7/dist-packages',
   '/home/flavio/git/web_prncpss',
   '/usr/lib/python2.7',
   '/usr/lib/python2.7/plat-x86_64-linux-gnu',
   '/usr/lib/python2.7/lib-tk',
   '/usr/lib/python2.7/lib-old',
   '/usr/lib/python2.7/lib-dynload',
   '/usr/local/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages/PILcompat',
   '/usr/lib/python2.7/dist-packages/gtk-2.0',
   '/usr/lib/pymodules/python2.7',
   '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
  
  Server time:    Sun, 13 Sep 2015 14:53:57 +0000
  </code></pre>
  
  <p><strong>EDIT 2 :</strong></p>
  
  <p>Full traceback : </p>
  
  <pre><code>Environment:
  
  
  Request Method: GET
  Request URL: http://127.0.0.1:8000/configs/?name=Coinbase&amp;name_cfg=MMConfig
  
  Django Version: 1.8.3
  Python Version: 2.7.9
  Installed Applications:
  ('django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'nested_admin',
   'accounting',
   'configs',
   'rest_framework')
  Installed Middleware:
  ('django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware')
  
  
  Traceback:
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
    132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
    58.         return view_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/viewsets.py" in view
    87.             return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch
    466.             response = self.handle_exception(exc)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch
    463.             response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/mixins.py" in list
    40.         queryset = self.filter_queryset(self.get_queryset())
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/generics.py" in filter_queryset
    151.             queryset = backend().filter_queryset(self.request, queryset, self)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/filters.py" in filter_queryset
    107.             for search_field in search_fields
  
  Exception Type: TypeError at /configs/
  Exception Value: 'NoneType' object is not iterable
  </code></pre>
  
  <p>Thanks a lot, </p>