📜  Django 自定义身份验证 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:08.846000             🧑  作者: Mango

代码示例4
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")