# error:unused variable username and password

I want to create a user authentication in django there is an error in username and password

def login(request):    if request.method=="POST":         #here got and error         username=request.POST.get('Username')         #here got an error         password=request.POST.get('password')         user = authenticate(username='username', password='password')         if user is not None:             return redirect("/")         else:             return render(request,'login.html')           return render(request,'login.html') 

Thanks in advance!

Add Comment
1 Answer(s)

This is because when you’re authenticating you’re using the string 'username' and the string 'password' rather than the variables you have created.

user = authenticate(username=username, password=password) 

Doing this you will now use the variables username and password rather than the strings.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.