pennersr / django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
https://allauth.org
MIT License
9.48k stars 3.02k forks source link

ImportError: allauth needs to be added to INSTALLED_APPS. #3387

Closed Suaralanre closed 1 year ago

Suaralanre commented 1 year ago

I need to use django-allauth. I've installed it in my venv, added it to installed apps and done all the necessary things according to the installation instructions on the Documentation. On running python manage.py migrate, the last line of the traceback error comes back as ImportError: allauth needs to be added to INSTALLED_APPS. This is my settings.py in the relevant areas

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "django.contrib.sites",

    # 3rd party libraries
    "rest_framework",
    "corsheaders",
    "rest_framework.authtoken",
    "allauth",
    "allauth.account",
    "allauth.socialaccount",
    "dj_rest_auth",
    "dj_rest_auth.registration",

    # Local
    "accounts",
    "posts",
]

....

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
                "django.template.context_processors.request",
            ],
        },
    },
]

....

AUTHENTICATION_BACKENDS = [
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
]

SITE_ID = 1

I tried checking the documentation, checked all the commas were put in the appropriate place. Looked for similar situations on reddit and stackoverflow but coudn't find anything along that line.

pennersr commented 1 year ago

I am sorry, but ticket is not actionable -- the example config includes various other non-allauth apps. I would suggest you try and remove accounts, dj_rest_auth and so on so that you have basic allauth going, and then gradually extend from there.

taime commented 1 year ago

I have the same problem, here is part from my settings file:

THIRD_PARTY_APPS = [ 'rest_framework', 'rest_framework.authtoken', 'twilio', 'django_filters', 'bootstrapform', 'corsheaders', 'storages', 'sorl.thumbnail', 'sorl_thumbnail_serializer', 'imagekit', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', 'rest_auth', 'rest_auth.registration', 'ckeditor', 'ckeditor_uploader', 'colorfield', 'gsheets', 'import_export', ]

xandris commented 1 year ago

@Suaralanre @taime see https://github.com/iMerica/dj-rest-auth/issues/534

I ran into this with Funkwhale (federated audio app). It uses dj_rest_auth as well. It tries to imprt email_address_exists from allauth.utils and interprets the exception as "allauth isn't in INSTALLED_APPS", but the real problem is email_address_exists was removed in 0.55.x.