title: Django REST framework: AttributeError: object has no attribute 'serializer'
body: <p>I have some issues with writing tests against Django REST API framework.
  I have Python 2.7.6 on Mac OS v.10.10.3, Django==1.6.5 and djangorestframework==3.1.1. I'm trying to write a couple of tests against Django REST framework.</p>
  
  <p>I have a dummy test view for the API:</p>
  
  <pre><code>class TestApiView(APIView):
      def get(self, request, format=None):
          return Response(status=status.HTTP_404_NOT_FOUND) 
  </code></pre>
  
  <p>It works just fine while I'm calling it:</p>
  
  <pre><code>(venv)bash-3.2# curl -H "Accept: application/json; indent=2" -i --request GET "http://127.0.0.1:8000/api/v1/client/test/"
  HTTP/1.0 404 NOT FOUND
  Date: Thu, 30 Apr 2015 18:35:09 GMT
  Server: WSGIServer/0.1 Python/2.7.6
  Vary: Accept, Cookie
  Allow: GET, HEAD, OPTIONS
  </code></pre>
  
  <p>But when I want to launch a Test against that view it raises exception.
  My test code:</p>
  
  <pre><code>from rest_framework.test import APIClient
  
  client = APIClient()
  print client.get('/api/v1/client/test/', format='json')
  </code></pre>
  
  <p>This code raises exception:</p>
  
  <pre><code>Internal Server Error: /api/v1/client/test/
  Traceback (most recent call last):
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
      response = response.render()
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/template/response.py", line 105, in render
      self.content = self.rendered_content
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/response.py", line 59, in rendered_content
      ret = renderer.render(self.data, media_type, context)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/renderers.py", line 333, in render
      form = data.serializer
  AttributeError: 'NoneType' object has no attribute 'serializer'
  Traceback (most recent call last):
    File "/Users/user/dev/managerv2/tests.py", line 20, in &lt;module&gt;
      print client.get('/api/v1/client/test/', format='json')
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 160, in get
      response = super(APIClient, self).get(path, data=data, **extra)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 86, in get
      return self.generic('GET', path, **r)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/compat.py", line 222, in generic
      return self.request(**r)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 157, in request
      return super(APIClient, self).request(**kwargs)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 109, in request
      request = super(APIRequestFactory, self).request(**kwargs)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/test/client.py", line 444, in request
      six.reraise(*exc_info)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
      response = response.render()
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/template/response.py", line 105, in render
      self.content = self.rendered_content
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/response.py", line 59, in rendered_content
      ret = renderer.render(self.data, media_type, context)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/renderers.py", line 333, in render
      form = data.serializer
  AttributeError: 'NoneType' object has no attribute 'serializer'
  </code></pre>
  
  <p>I have almost the same issue with views based on mixins.ListModelMixin - it works fine, but raises exception during testing.</p>
  
  <p>View definition:</p>
  
  <pre><code>class ListTestView(mixins.ListModelMixin, generics.GenericAPIView):
  
      pagination_class = paginators.StandardResultsSetPagination
  
      def get(self, request, format=None, *args, **kwargs):
          self.serializer_class = TestListSerializer
          self.queryset = Client.objects.all()
          return self.list(request, *args, **kwargs)
  </code></pre>
  
  <p>Calling this view from the test client:</p>
  
  <pre><code>print client.get('/api/v1/client/list/', format='json')
  </code></pre>
  
  <p>raises this exception:</p>
  
  <pre><code>Internal Server Error: /api/v1/client/list/
  Traceback (most recent call last):
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
      response = response.render()
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/template/response.py", line 105, in render
      self.content = self.rendered_content
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/response.py", line 59, in rendered_content
      ret = renderer.render(self.data, media_type, context)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/renderers.py", line 333, in render
      form = data.serializer
  AttributeError: 'OrderedDict' object has no attribute 'serializer'
  Traceback (most recent call last):
    File "/Users/user/dev/managerv2/tests.py", line 22, in &lt;module&gt;
      print client.get('/api/v1/client/golden_state/list/1/', format='json')
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 160, in get
      response = super(APIClient, self).get(path, data=data, **extra)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 86, in get
      return self.generic('GET', path, **r)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/compat.py", line 222, in generic
      return self.request(**r)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 157, in request
      return super(APIClient, self).request(**kwargs)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/test.py", line 109, in request
      request = super(APIRequestFactory, self).request(**kwargs)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/test/client.py", line 444, in request
      six.reraise(*exc_info)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
      response = response.render()
    File "/Users/user/dev/venv/lib/python2.7/site-packages/django/template/response.py", line 105, in render
      self.content = self.rendered_content
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/response.py", line 59, in rendered_content
      ret = renderer.render(self.data, media_type, context)
    File "/Users/user/dev/venv/lib/python2.7/site-packages/rest_framework/renderers.py", line 333, in render
      form = data.serializer
  AttributeError: 'OrderedDict' object has no attribute 'serializer'
  </code></pre>
  
  <p>Any suggestions? Many thanks!</p>