title: Broken pipe from ('127.0.0.1', 57124)
body: <p>Well, I have written the following code to make a login functionality at backend using django 1.10 and mongoengine 0.9.0 (MongoDB),here is the code:</p>
  
  <pre><code>@csrf_exempt
  def check_auth(request):
     csrf_dict = {}
     csrf_dict.update(csrf(request))
     username = json.loads(request.body)['username']
     password = json.loads(request.body)['pwd']
     try:
       user = User.objects.get(username=username)
       if user.check_password(password):
          user.backend = 'mongoengine.django.auth.MongoEngineBackend'
          user = authenticate(username=username, password=password)
          login(request, user)
          request.session.set_expiry(60 * 60 * 1)
          user_id = str(user.pk)
          print HttpResponse.status_code
          if request.POST.has_key('next'):
              return redirect(request.POST['next'])
          else:
              return redirect('/dashboard/home')
      else:
          return redirect('/dashboard/login')
  except DoesNotExist:
      return redirect('/dashboard/login')
  </code></pre>
  
  <p>response code is 200, but it is not redirecting page to home,  instead it is giving me the error:</p>
  
  <pre><code>[04/Feb/2017 06:00:05] "POST /dashboard/check_auth HTTP/1.1" 302 0
  [2017-02-04 06:00:05,223] - Broken pipe from ('127.0.0.1', 57124)
  </code></pre>
  
  <p>Please suggest to resolve this issue. </p>