ImportError: allauth 需要添加到 INSTALLED_APPS

Sua*_*nre 3 django python-3.x django-rest-framework django-allauth

我一直在关注 William Vincent 撰写的关于 django for apis 的教程。我需要使用 django-allauth。我已将其安装在我的 venv 中,将其添加到已安装的应用程序中,并根据 Documentation 上的安装说明完成了所有必要的操作。运行时python manage.py migrate,错误返回为ImportError: allauth needs to be added to INSTALLED_APPS.

这是我的settings.py中的相关区域

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",
]
Run Code Online (Sandbox Code Playgroud)

我很感谢您提前提供的帮助。

我尝试检查文档,检查所有逗号是否都放在适当的位置。在 reddit 和 stackoverflow 上寻找类似的情况,但找不到任何相关内容。

小智 7

最新版本allauth的问题,dj_rest_auth还不兼容。将 pipfile 上的 allauth 版本更改为 0.54.0

django-allauth = "==0.54.0"