title: Django APIClient login not working
body: <p>I'm having problem authenticating with my Django Rest Framework API in Unit Unit Tests. The system works as expected when accessing it through the browser. I however receive a 401 HTTP status when sending a put request to the following class at the following endpoint: </p>
  
  <pre><code>class UserDetail(RetrieveModelMixin, DestroyModelMixin, UpdateModelMixin, GenericViewSet):
      authentication_classes = (BasicAuthentication, TokenAuthentication)
      permission_classes = IsAuthenticated,
      queryset = CustomUser.objects.all()
      serializer_class = UserSerializer
  </code></pre>
  
  <p>The test below is as follows: </p>
  
  <pre><code>class AccountTests(APITestCase):
  
      def setUp(self):
          self.user = CustomUser.objects.create_user(email="user1@test.com", password="password1", is_staff=True)
          self.user.save()
          self.user = CustomUser.objects.get(email="user1@test.com")
          self.client = APIClient()
  
      def test_add_name(self):
          self.client.login(email="user1@test.com", password='password1')
          url = reverse('customuser-detail', args=(self.user.id,))
          data = {'first_name': 'test', 'last_name': 'user'}
  
          self.client.login(email="user1@test.com", password='password1')
          response = self.client.put(url, data, format='json')
  
          self.assertEqual(response.status_code, status.HTTP_200_OK)
  </code></pre>
  
  <p>When printing the response.data, I receive:</p>
  
  <pre><code>{u'detail': u'Authentication credentials were not provided.'}
  </code></pre>
  
  <p>The client.login(...) method returns true, but the credentials do not appear to be attached to the header. My experiments in the IsAuthenticated permission classes had an request.user = AnonymousUser. In the BasicAuthentication class, auth = None.</p>
  
  <p>Am I missing something as regards to using BasicAuth in settings.py? Or even in the test itself? </p>
  
  <p>Thanks.</p>