title: MultiValueDictKeyError at /login/ "u'username'"
body: <p>I am trying to build a web api for a login page. I keep getting this error. Although i have seen similar and related issues online, the solutions have been of help to me. What am i not doing right?</p>
  
  <p><strong>error</strong></p>
  
  <pre><code>MultiValueDictKeyError at /login/
  "u'username'"
  </code></pre>
  
  <p><strong>login</strong></p>
  
  <pre><code>@csrf_exempt
      def my_view(request):
           user = request.POST['username']
           passcode = request.POST['password']
           user = authenticate(request, username=user, password = passcode)
           if user is not None:
               login(request, user)
               return HttpResponse("User logged in")
  
           else:
               return HttpResponse("User not found")
  </code></pre>
  
  <p><strong>updated login</strong></p>
  
  <pre><code>@csrf_exempt
  def my_view(request):
       if request.method == 'POST':
          user = request.POST['username']
          passcode = request.POST['password']
          user = authenticate(request, username=user, password = passcode)
          if user is not None:
              login(request, user)
              return HttpResponse("User logged in")
  
          else:
              return HttpResponse("User not found")
  </code></pre>