login() missing 1 required positional argument: 'user'
12,300
You're not using the right view, try this instead
path('login',views.login_view, name = 'login ')
Related videos on Youtube
![AJAY RAWAT](https://lh5.googleusercontent.com/-21cFwjXJtP4/AAAAAAAAAAI/AAAAAAAAAAA/AAnnY7pm5y9pDBuMhITuJV9QuOKKqd2odw/mo/photo.jpg?sz=256)
Author by
AJAY RAWAT
Updated on June 04, 2022Comments
-
AJAY RAWAT about 2 years
Here is my view,
def login_view(request) : if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): email = form.cleaned_data['email'] password = form.cleaned_data['password'] user = authenticate(email=email, password=password) if user is not None: form = LoginForm() login(request, user)
I get an error:
login() missing 1 required positional argument: 'user'
Also, I am using a custom user model
My
urls.py
:urlpatterns = [ path('',views.register, name='register' ), path('form',views.form, name = 'form'), path('login',views.login, name = 'login ')]
-
scharette almost 6 yearsCan we see your
urls.py
-
AJAY RAWAT almost 6 yearsSure . I’ll add it
-
AJAY RAWAT almost 6 years@scharette Please suggest a solution, thanks : )
-
Willem Van Onsem almost 6 yearsYou probably overwrote
login
somewhere with another function.
-
-
AJAY RAWAT almost 6 yearsThank you very much
-
AJAY RAWAT almost 6 yearsI forgot to change that. My bad 😅. It is running smoothly now. Thanks :)
-
scharette almost 6 yearsThis answer is confusing. Could you give OP more insights on what is the purpose of your solution ?
-
AJAY RAWAT almost 6 yearsYou are correct. The error was in the urls. Thanks :)
-
Sam almost 6 yearsoh my bad. Did not notice that.