"ModuleNotFoundError: No module named 'allauth.account.middleware'"
I keep getting this error in my django project even when django-allauth is all installed and setup???
I tried even reinstalling and changing my python to python3 but didn't change anything, can't figure out why all other imports are working but the MIDDLEWARE one...
Help pls?
settings.py:
"""
Django settings for youtube2blog2 project.
Generated by 'django-admin startproject' using Django 4.2.4.
For more information on this file, see
For the full list of settings and their values, see
"""
from pathlib import Path
import django
import os
import logging
import pyfiglet
import allauth
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'omegalul'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# CUSTOM CODE
# os.environ['FFMPEG_PATH'] = '/third-party/ffmpeg.exe'
# os.environ['FFPROBE_PATH'] = '/third-party/ffplay.exe'
OFFLINE_VERSION = False
def offline_version_setup(databases):
if (OFFLINE_VERSION):
# WRITE CODE TO REPLACE DATABASES DICT DATA FOR OFFLINE SETUP HERE
return True
return
banner_ascii_art = pyfiglet.figlet_format("CHRIST IS KING ENTERPRISES")
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
print("\n - CURRENT DJANGO VERSION: " + str(django.get_version()))
print("\n - settings.py: Current logger level is " + str(logger.getEffectiveLevel()))
logger.debug('settings.py: Logger is working.\n\n')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by email
'allauth.account.auth_backends.AuthenticationBackend',
]
'''
NEEDED SETUP FOR SOCIAL AUTH
REQUIRES DEVELOPER CREDENTIALS
ON PAUSE UNTIL MVP IS DONE
# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
'google': {
# For each OAuth based provider, either add a ``SocialApp``
# (``socialaccount`` app) containing the required client
# credentials, or list them here:
'APP': {
'client_id': '123',
'secret': '456',
'key': ''
}
}
'apple': {
}
'discord' {
}
}
'''
LOGIN_REDIRECT_URL = 'dashboard'
#
# Application definition
INSTALLED_APPS = [
# My Apps
'yt2b2',
'home',
'dashboard',
# Django Apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Downloaded Apps
'rest_framework',
'embed_video',
'allauth',
'allauth.account',
'allauth.socialaccount',
#'allauth.socialaccount.providers.google',
#'allauth.socialaccount.providers.apple',
#'allauth.socialaccount.providers.discord',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Downloaded Middleware
'allauth.account.middleware.AccountMiddleware',
]
ROOT_URLCONF = 'youtube2blog2.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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',
],
},
},
]
WSGI_APPLICATION = 'youtube2blog2.wsgi.application'
# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3', # <--------- OFFLINE VERSION
# Consider masking these secret variables using a .env file to beef up your Django app's security. Besides, Vercel allows you to list your environment variables during deployment.
#'URL' : 'postgresql://postgres:oibkk5LL9sI5dzY5PAnj@containers-us-west-128.railway.app:5968/railway',
#'NAME' : 'railway',
#'USER' : 'postgres',
#'PASSWORD' : 'oibkk5LL9sI5dzY5PAnj',
#'HOST' : 'containers-us-west-128.railway.app',
#'PORT' : '5968'
}
}
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/' # the path in url
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
# Default primary key field type
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
Tried changing to python3, reinstalling django-allauth through pip, other stackoverflow solutions, shifting through allauth docs... Nothing worked until now
Update: removed https links because of spam filter
Error location:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Downloaded Middleware
'allauth.account.middleware.AccountMiddleware',
]
The middleware is only present in the unreleased 0.56.0-dev, likely you are using 0.55.2 and following 0.56 documentation.