django未经授权的响应问题403

django未经授权的响应问题403,django,Django,在下面的代码中如何发布403进行未授权 user = authenticate(username=username, password=password) if user is not None: # the password verified for the user if user.is_active: print("User is valid, active and authenticated") return HttpResponse(

在下面的代码中如何发布403进行未授权

user = authenticate(username=username, password=password)
  if user is not None:
     # the password verified for the user
     if user.is_active:
       print("User is valid, active and authenticated")
       return HttpResponse("Authorized")
     else:
       print("The password is valid, but the account has been disabled!")
       return HttpResponse("Unauthorized")
  else:
      # the authentication system was unable to verify the username and password
      print("The username and password were incorrect.")
      return HttpResponse("Unauthorized")
你在找我

行为与此类似,但使用403状态代码

可能重复的