title: KeyError at /login/ 'is_login' Request Method: django
body: <p><a href="https://i.stack.imgur.com/fSd2z.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I am coding web with django. I can not use session. I wanna check login use session </p>
  
  <pre><code>def user_login(request):
      if request.session['is_login'] == True:
          return HttpResponseRedirect('/home')
      else:
          next = request.POST.get('next', request.GET.get('next', ''))
          if request.method == "POST":
              username1 = request.POST.get('username')
              password1 = request.POST.get('password')
              user = authenticate(username=username1, password=password1)
              if user is not None:
                  if user.is_active:
                      login(request, user)
                      if next:
                          request.session['is_login'] = True
                          return HttpResponseRedirect(next)
  
                      return HttpResponseRedirect('/home')
  
                  else:
                      return HttpResponse('Inactive user')
              else:
                  return HttpResponseRedirect(LOGIN_URL)
          return render(request, "pages/login.html")
  </code></pre>
  
  <p>How to fix</p>