title: Django Rest Framework returns 200 OK even though login request has incorrect credentials
body: <p>This is my URLS.py:</p>
  
  <pre><code>from django.conf.urls import include, url
  from django.contrib import admin
  
  urlpatterns = [
      url(r'^CMS/', include('CMSApp.urls')),
      url(r'^admin/', include(admin.site.urls)),
  ]
  </code></pre>
  
  <p>and this is CMSApp/urls.py:</p>
  
  <pre><code>from django.conf.urls import url
  from django.conf.urls import include
  from CMSApp import views
  
  urlpatterns = [
      url(r'^$', views.HomePageView.as_view()),
      url(r'^users$', views.user_list.as_view()),
      url(r'^users/(?P&lt;pk&gt;[0-9]+)$', views.user_detail.as_view()),
      url(r'^api-auth/', include('rest_framework.urls',
                                     namespace='rest_framework')),
  ]
  </code></pre>
  
  <p>My HomePageView serves this home.html page:</p>
  
  <pre><code>&lt;h3&gt;Register&lt;/h3&gt;
  &lt;form ng-submit="ctrl.add()" name="myForm"&gt;
      &lt;label&gt;Username&lt;/label&gt;
      &lt;input type="text" name="uname" ng-model="ctrl.user.username" required&gt; 
      &lt;label&gt;Password&lt;/label&gt;
      &lt;input type="password" name="pwd" ng-model="ctrl.user.password" required&gt;
      &lt;label&gt;Email&lt;/label&gt;
      &lt;input type="email" name="mail" ng-model="ctrl.user.email" required&gt; 
      &lt;input type="submit" value="Register"&gt; 
  &lt;/form&gt;
  
  &lt;h3&gt;Login&lt;/h3&gt;
  &lt;form ng-submit="ctrl.loginUser()" name="myLoginForm"&gt;
      &lt;label&gt;Username&lt;/label&gt;
      &lt;input type="text" name="uname" ng-model="ctrl.user.username" required&gt; 
      &lt;label&gt;Password&lt;/label&gt;
      &lt;input type="password" name="pwd" ng-model="ctrl.user.password" required&gt;
      &lt;input type="submit" value="Login"&gt; 
  &lt;/form&gt;
  
  &lt;script&gt;
  angular.module("notesApp", [])
      .config(['$httpProvider', function($httpProvider) {
          $httpProvider.defaults.xsrfCookieName = 'csrftoken';
          $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
      }])
  
      .controller("MainCtrl", ["$http", function($http) {
      var self = this;
      self.users = {};
      var fetchUsers = function() {
          return $http.get("/CMS/users").then(function(response) { // get list of existing users
              self.users = response.data;
          }, function(errResponse) {
          console.error("Error while fetching users.");
          });
      };
  
      self.loginUser = function() {
          $http.post("/CMS/api-auth/login/", self.user)
          .error(function(data, status, headers, config) {
              console.log(data);
           })
          .then(fetchUsers);
  
          console.log("Success Login with ", self.user);
      };
      }]);
  &lt;/script&gt;
  </code></pre>
  
  <p>When I register a user which already exists, then Django returns a 400 Bad Request error, which is good because I use AngularJS on the frontend to handle the 400 status code. </p>
  
  <p>The issue is, when I try to log in with an incorrect username and password (a username which does not exist or a username and password which do not match), Django returns a 200 OK status code so I can't track the issue using AngularJS on the frontend. Any idea why Django returns a 200 OK when I try to log in with an incorrect username and password? How do I get Django to return a 400 when an incorrect username / password is submitted?</p>
  
  <p>Edit: This was my original post: <a href="https://stackoverflow.com/questions/31598792/django-rest-framework-angularjs-not-logging-user-in-or-throwing-errors?noredirect=1#comment51153428_31598792">Django Rest Framework + AngularJS not logging user in or throwing errors</a> and charlietfl commented on it saying "as for the ajax error handling. If login fails .... using true REST methodology would send back a 401 status which would then fire your ajax error handler", which is why I do not want a 200 OK when login fails.</p>