python - 没有名为 rest_authusers 的模块错误

标签 python django django-rest-framework django-allauth

我正在按照本教程将 allauth 添加到我的项目中: http://django-allauth.readthedocs.org/en/latest/installation.html

尝试进行迁移时出现以下错误: “导入错误:没有名为 rest_authusers 的模块”

我的settings.py如下:

   # Application definition
    INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'rest_framework',
        'rest_framework.authtoken',
        'rest_auth'
        'users',
        # The Django sites framework is required
        'django.contrib.sites',
        'allauth.socialaccount.providers.facebook',
    )

    SITE_ID = 1

    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'django.middleware.security.SecurityMiddleware',
    )
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(SETTINGS_PATH, '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',
                # `allauth` needs this from django
                'django.template.context_processors.request',
            ],
        },
    },
]


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 e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
)
AUTH_USER_MODEL = 'users.UserProfile'

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    )
}

此外,我不确定如何解决此问题,因为我的项目文件中没有对 authusers 的引用。

回溯:https://dpaste.de/2SDB

最佳答案

你只是忘了在 'rest_auth' 之后加上逗号 ;)

关于python - 没有名为 rest_authusers 的模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33968972/

相关文章:

python - Anaconda 找不到 OpenCV

python - 在 Linux 中使用 sudoers 将文件的所有者从用户更改为 root

python - 使用 wx.image 缩放图片

python - OTP 验证时 JWT token 不匹配

Django 内容类型表 - 身份验证权限

python - 在 Django REST 框架中序列化查询集

javascript - mac os x python/JavaScript IDE,我可以在其中使用断点

python - Django:模板中的变量中的变量

djangorest框架序列化模型以返回其str表示

python - Django DRF - 通过权限限制对 ListView 的访问