Django valueError at /login/

 I am trying to implement a signup page for my django project but after the data gets passed from the login template to my loginPage view it outputs the error below

You have multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user.

Below is the code for my login page view

def loginpage(request):

    if request.user.is_authenticated:
        return redirect('home')
    form = Login_form
    if request.method == "POST":
        user = authenticate(request, username=username, password=password)

        if user is not None:
            login(request, user)
            return redirect('home')
    else:, 'Email OR Password is incorrect')

    context = {}
    return render(request, 'login.html', context)


message profile

 This error occurs because you have set more than one authentication backend in your projects and django doesn't know the specific one you want to use for this particular authenticaton process.

I had this same error when I attempted to implement social authentication like google and facebook in my website. My authentication backend in looked like this


A quick fix is to simply specify the backend you want to use in your loginpage view.

For example lets say you wish to use django's default authentication backend then simply change the code below.

login(request, user)


login(request, user, backend = 'django.contrib.auth.backends.ModelBackend')


Add Message

Click on the button below to add a new message to this thread


Thread detail

Satus: Open
Messages: 1Started: 2022-05-24




Frontend Development |Backend Development |Full Website Development |Bootstrap Website upgrades | Website Debbugging | Website Hosting & deployment


Interested in hiring me or collaborating with me on a project, click on any of the links below to get my social media handle

Or contact me via Tel: (+234)-806-225-7480 | Email:
Privacy Policy

By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.