You're using the same name login
as a view name; this shadows the function you want call.
Use a different name for the view.
Or call login
function with qualified form:
django.contrib.auth.login(request, auth_form.get_user())
Frage
i get this error when trying to use the 'login()'
login() takes exactly 1 argument (2 given)
Now i use this to handle my userlogin, and im pretty sure it worked before i copied it. tho now it tells me i give 2 arguments except 1.
my login view:
def login(request):
"""Logs a user into the application."""
auth_form = AuthenticationForm(None, request.POST or None)
# The form itself handles authentication and checking to make sure passowrd and such are supplied.
if auth_form.is_valid():
login(request, auth_form.get_user())
return HttpResponseRedirect(reverse('index'))
return render(request, 'login.html', {'auth_form': auth_form})
dont got any idea what im doing wrong.
Lösung
You're using the same name login
as a view name; this shadows the function you want call.
Use a different name for the view.
Or call login
function with qualified form:
django.contrib.auth.login(request, auth_form.get_user())