code: def login(request, template_name='registration/login.html',
            redirect_field_name=REDIRECT_FIELD_NAME,
            authentication_form=AuthenticationForm,
            current_app=None, extra_context=None):
      
      redirect_to = request.POST.get(redirect_field_name,
                                     request.GET.get(redirect_field_name, ''))
  
      if request.method == "POST":
          form = authentication_form(data=request.POST, request=request)
          if form.is_valid():
              netloc = urlparse(redirect_to)[1]
  
              # Use default setting if redirect_to is empty
              if not redirect_to:
                  redirect_to = settings.LOGIN_REDIRECT_URL
  
              # Heavier security check -- don't allow redirection to a different
              # host.
              elif netloc and netloc != request.get_host():
                  redirect_to = settings.LOGIN_REDIRECT_URL
  
              # Okay, security checks complete. Log the user in.
              auth_login(request, form.get_user())
  
              return redirect(redirect_to)
      else:
          form = authentication_form(request)
  
      current_site = get_current_site(request)
  
      context = {
          'form': form,
          redirect_field_name: redirect_to,
          'site': current_site,
          'site_name': current_site.name,
      }
      if extra_context is not None:
          context.update(extra_context)
      request.current_app = current_app
      return TemplateResponse(request, template_name, context)
docs: Displays the login form and handles the login action.