title: MultiValueDictKeyError in Django when use POST
body: <p>I am new to Django rest framework and was asked to write the token authentication part of our project. One thing to note is, as I would use not use the default admin site in future, I write login, logout, signup functions, and test the functionality by POSTMAN. What I want to do now is to let new user signup, login and logout. When a user log in, I issue him/her a token. Everything just perform in the easiest way.</p>
  
  <p>But I still can't work it out. I searched all the related questions but still cannot solve my problem. If someone know how to do, please help me! 
  Following is the details.</p>
  
  <p>When I am using GET, everything works fine. But when I am using POST, I get MultiValueDictKeyError. I don't know why.</p>
  
  <p><strong>View.py</strong></p>
  
  <pre><code>    from rest_framework.response import Response
      from django.contrib.auth import authenticate
      from rest_framework.authtoken.models import Token
      from rest_framework import status
      from django.contrib.auth.models import User
      from rest_framework.authentication import TokenAuthentication
      from rest_framework.permissions import IsAuthenticated
      from django.contrib.auth.signals import user_logged_in, user_logged_out
      from rest_framework.decorators import api_view, authentication_classes, permission_classes
      from django.views.decorators.csrf import csrf_exempt, requires_csrf_token
      @csrf_exempt
      @requires_csrf_token
      @api_view(['POST'])
      def create_user_view(request):
          if request.method == 'POST':
              username = request.POST['username']
              email = request.POST['email']
              password = request.POST['password']
              user = User.objects.create_user(username=username, email=email,     password=password)
              user.save()
              return Response({'detail': "Create user"})
  
  
      @csrf_exempt
      def login_view(request):
           if request.method == 'POST':
              username = request.POST['username']
              password = request.POST['password']
              user = authenticate(username=username, password=password)
           if user is not None:
              user_logged_in.send(sender=user.__class__, request=request, user=user)
              token = Token.objects.get_or_create(user=user)
              return Response({
                             'detail': 'POST answer', 'token': token[0].key,
                             })
          else:
              return Response({'detail': "The username or password were incorrect.",
             status: status.HTTP_404_NOT_FOUND})
  
      @csrf_exempt
      def logout_view(request):
          if request.method == 'POST':
              user = getattr(request, 'user', None)
              if hasattr(user, 'is_authenticated') and not user.is_authenticated():
                  user = None
                  user_logged_out.send(sender=user.__class__, request=request, user=user)
              if hasattr(request, 'user'):
                   from django.contrib.auth.models import AnonymousUser
  
                   request.user = AnonymousUser()
             return Response({'detail': "You have logged out successfully."})
  </code></pre>
  
  <p><strong>Test_app/Urls.py</strong></p>
  
  <pre><code>    from django.conf.urls import patterns, url
      from rest_framework.urlpatterns import format_suffix_patterns
      from test_app import views
      urlpatterns = patterns('test_app.views',
                             url(r'^signup', views.create_user_view),
                             url(r'^login', views.login_view),
                             url(r'^logout', views.logout_view),
                             url(r'^auth', views.AuthView),
                             )
      urlpatterns = format_suffix_patterns(urlpatterns)
  </code></pre>
  
  <p><strong>Models.py(Yes, I only put two lines in the file)</strong></p>
  
  <pre><code>    from django.contrib.auth.models import User
      from django.db import models
  </code></pre>
  
  <p>I also modified settings.py as tutorial said. </p>
  
  <p>The problem now is:</p>
  
  <pre><code>Request Method: POST
  Request URL:    http://127.0.0.1:8000/signup?username=haha&amp;email=haha@gmail.com&amp;password=okok
  Django Version: 1.8.2
  Exception Type: MultiValueDictKeyError
  Exception Value:    
  "'username'"
  Exception Location: /Users/wyq/PycharmProjects/env/lib/python2.7/site-packages/django/utils/datastructures.py in __getitem__, line 322
  </code></pre>
  
  <p>Can anyone help? Thank you very much!</p>