📅  最后修改于: 2022-03-11 14:45:08.846000             🧑  作者: Mango
def getLogin(request):
if request.user.is_authenticated:
return redirect('index')
else:
if request.method == "POST":
user = request.POST.get('user')
password = request.POST.get('pass')
auth = authenticate(request, username=user, password=password)
if auth is not None:
login(request, auth)
return redirect('index')
return render(request, "login.html")