[Python] login(request, user) not working in python django

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    This is my page url within the urls.py file:

    path('login/',views.login_view, name="login"),


    This is my page view with the views.py file:

    def login_view(request):
    if request.method == "POST":
    user_name = request.POST.get("username")
    pass_word = request.POST.get("password")
    user = authenticate(request, username=user_name, password=pass_word)
    # print("user1 -->", user)

    if user is not None:
    # print("user-->",user)
    login(request, user)
    return render(request, "index.html")
    else:
    return render(request,"http://127.0.0.1:8000/login")
    else:
    # return render(request, "order.html")
    return render(request, "login.html")


    The error I am getting is:

    TypeError at /login/logincheck/login() missing 1 required positional argument: 'user'

    Continue reading...

Compartilhe esta Página