[PYTHON] How to deal with "You have multiple authentication backends configured ..." (Django)

About this article

There was no workaround written in Japanese, so I will write it down.

Occurrence of problem

In the application created with Django, when creating a User and logging in as that user, the following error occurs.

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

Cause

Even though multiple AUTHENTICATION_BACKENDS were used, backend was not specified in the login process.

views.py


#User registration screen

#Login process
login(self.request, user) #Error here

settings.py



AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend', # ID/pass
    'allauth.account.auth_backends.AuthenticationBackend', #social
)

approach

I specified backend.

views.py


#User registration screen

#Login process
login(self.request, user, backend='django.contrib.auth.backends.ModelBackend')

result

solved. You had to specify the backend.

Recommended Posts

How to deal with "You have multiple authentication backends configured ..." (Django)
How to deal with imbalanced data
How to deal with imbalanced data
How to deal with DistributionNotFound errors
How to get started with Django
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to do arithmetic with Django template
How to title multiple figures with matplotlib
How to deal with enum compatibility errors
[Python] How to deal with module errors
How to deal with garbled characters in json of Django REST Framework
How to deal with memory leaks in matplotlib.pyplot
How to deal with errors when hitting pip ②
How to develop a cart app with Django
[Python] How to draw multiple graphs with Matplotlib
can't pickle annoy. How to deal with Annoy objects
How to deal with run-time errors in subprocess.call
How to deal with module'tensorflow' has no attribute'〇〇'
How to deal with SessionNotCreatedException when using Selenium
How to implement "named_scope" of RubyOnRails with Django
How to return multiple indexes with index method
How to get multiple model objects randomly in Django
How to deal with Django's Template Does Not Exist
How to deal with pyenv initialization failure in fish 3.1.0
When you want to filter with Django REST framework
[Python] How to deal with pandas read_html read error
Things to do when you start developing with Django
How to deal with Executing transaction: failed in Anaconda
Summary of how to share state with multiple functions
How to register the same data multiple times with one input on the Django management screen
How to embed multiple embeds in one message with Discord.py
How to handle static files when deploying to production with Django
How to check ORM behavior in one file with django
[Django] How to give input values in advance with ModelForm
How to resolve CSRF Protection when using AngularJS with Django
[Linux] How to deal with garbled characters when viewing files
I'm trying to create an authentication / authorization process with Django
[AWS] How to deal with "Invalid codepoint" error in CloudSearch
A story about how to deal with the CORS problem
For beginners, how to deal with common errors in keras
How to deal with UnicodeDecodeError when executing google image download
How to update with SQLAlchemy?
How to cast with Theano
How to Alter with SQLAlchemy?
How to separate strings with','
How to RDP with Fedora31
2 ways to deal with SessionNotCreatedException
How to Delete with SQLAlchemy?
How to deal with the error "Failed to load module" canberra-gtk-module "that appears when you run OpenCV
Python Django How to deal with cases where Japanese carrier emails are played by Email Validator
How to deal with python installation error in pyenv (BUILD FAILED)
How to deal with errors when installing whitenoise and deploying to Heroku
Here's a brief summary of how to get started with Django
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to deal with errors when installing Python and pip with choco
[Tips] How to do template extends when creating HTML with django
How to cancel RT with tweepy
Python: How to use async with
[Django] How to test Form [TDD]
Connect to multiple databases with SQLAlchemy