[Fixed] ImportError: allauth needs to be added to INSTALLED_APPS – Python-3.x

by
Alexei Petrov
django django-allauth django-rest-framework python-3.x

Quick Fix: If you’re using the latest version of allauth, which is not compatible with dj_rest_auth, change your allauth version on your pipfile to 0.54.0.

The Problem:

I added the django-allauth package to my Django project and followed the installation instructions. However, when I try to run ‘python manage.py migrate,’ I get an ‘ImportError: allauth needs to be added to INSTALLED_APPS.’ error. Upon checking, I found that ‘allauth’ is already included in INSTALLED_APPS in my settings.py. I need help troubleshooting this issue and ensuring that django-allauth is correctly configured.

The Solutions:

Solution 1: Downgrade allauth version to 0.54.0

The error "ImportError: allauth needs to be added to INSTALLED_APPS" is likely due to a compatibility issue between the latest version of allauth and dj_rest_auth. To fix this, you can downgrade your allauth version to 0.54.0, which is compatible with dj_rest_auth.

To do this, open your pipfile and change the version of allauth to 0.54.0 as shown below:

django-allauth = "==0.54.0"

Save the changes and run the following command to downgrade allauth:

pipenv install

Once the installation is complete, you should be able to successfully run python manage.py migrate without encountering the error.

Solution 2: Downgrading django-allauth

The issue may be caused by the version of “django-allauth” being used. If you are using version 0.55.0, try downgrading it to version 0.54.0 and see if that resolves the problem.

Solution 3: Upgrade dj_rest_auth

If you’re upgrading django-allauth from an older version to a newer one you may encounter the error `ImportError: allauth needs to be added to INSTALLED_APPS.` even though you have added it to your settings. This can be fixed by upgrading dj_rest_auth as well. At the time of writing this response the latest version of dj_rest_auth is 5.0.2. Upgrade dj_rest_auth to this version and the error should disappear.

Solution 4: Deleting try in dj_rest_auth registration serializers.py

There is a try in the imports section in the file site-packages\dj_rest_auth\registration\serializers.py. Delete and you will realize that the library is broken.

Q&A

What’s the reason for the error?

Latest version of allauth and dj_rest_auth is not compatible.

How to fix the error?

Change to a compatible version of allauth.

Which version of allauth is compatible with dj_rest_auth?

0.54.0.