title: Django REST User Login
body: <p>I am looking to login a user with a username and password in django. This is my code:</p>
  <pre><code>if request.method == 'POST':
  
          username = request.data.get('username')
          password = request.data.get('password')
  
          user = authenticate(username=username, password=password)
          if user is not None:
              login(request, user=user)
              return Response({'Message': &quot;Success!&quot;}, status=status.HTTP_200_OK)
          else:
              return Response({&quot;Message&quot;: &quot;Invalid&quot;}, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  <p>The authentication works fine, but when i go to login i get this:</p>
  <pre><code>AssertionError: The `request` argument must be an instance of `django.http.HttpRequest`, 
  not `rest_framework.request.Request`.
  </code></pre>
  <p>I am using the rest API, and my request looks like this</p>
  <pre><code>function login() {
          const requestOptions = {
              method: &quot;POST&quot;,
              headers: {
                  &quot;Content-Type&quot;: &quot;application/json&quot;,
                  'X-CSRFToken': getCookie('csrftoken')
              },
              credentials: 'include',
              body: JSON.stringify({
                  username: username,
                  password: password,
              }),
          };
          fetch(&quot;/users/login/&quot;, requestOptions)
              .then((response) =&gt; response.json())
              .then((data) =&gt; setStatus(data.Message))
      }
  </code></pre>
  <p>Would anyone know how to create a django request to log the user in? Thanks!</p>