Django allauth 注册视图无法协同工作

Django allauth signup view not working coorecly

我在注册 allauth 时遇到问题。 我正在尝试添加新帐户,但尝试时出现此错误。 其他功能(登录、注销和其他密码工作)正在运行。
其他视图正常但 singup 不工作,当我想添加新用户时,我遇到了这个问题。

Internal Server Error: /accounts/signup/
Traceback (most recent call last):
File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- 
packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- 
packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- 
packages/django/views/generic/base.py", line 70, in view
.
.
.
return super(CloseableSignupMixin, self).dispatch(request,
File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- 
packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site-packport_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'some'

我还没有写任何代码,因为我刚刚开始项目,我想在项目中集成到 allauth 我的目录是:

enter code here
essahmi
├── __pycache__
└── settings
    └── __pycache__
home
├── migrations
│   └── __pycache__
└── __pycache__
templates
├── account
├── allauth
│   └── account
│       ├── email
│       ├── messages
│       └── snippets
├── base
│   └── companent
└── home
static/
├── css
├── img
└── js

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',
    #my app
    'home',

    # third party apps

    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'crispy_forms',
]

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',
]

ROOT_URLCONF = 'essahmi.urls'

TEMPLATES = [
    {
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR,'templates'),os.path.join(BASE_DIR,'templates','allauth'),],
    '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',
            # For allouth
            'django.template.context_processors.request',
        ],
    },
    },
]
WSGI_APPLICATION = 'essahmi.wsgi.application'





# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

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
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'tr'

TIME_ZONE = 'Europe/Istanbul'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = 'static/'

MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')



# allauth settings

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

SITE_ID = 1
LOGIN_REDIRECT_URL = "/"
ACCOUNT_USERNAME_VALIDATORS = 'some.module.validators.custom_username_validators'
ACCOUNT_EMAIL_REQUIRED = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

ACCOUNT_FORMS = {
    'login': 'allauth.account.forms.LoginForm',
    'signup': 'allauth.account.forms.SignupForm',
    'add_email': 'allauth.account.forms.AddEmailForm',
    'change_password': 'allauth.account.forms.ChangePasswordForm',
    'set_password': 'allauth.account.forms.SetPasswordForm',
    'reset_password': 'allauth.account.forms.ResetPasswordForm',
    'reset_password_from_key': 'allauth.account.forms.ResetPasswordKeyForm',
    'disconnect': 'allauth.socialaccount.forms.DisconnectForm',
}

# crispy form settings
CRISPY_TEMPLATE_PACK = 'bootstrap4'

from essahmi.settings.base import *


DEBUG = True


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

DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': BASE_DIR / 'db.sqlite3',
    }
}


STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

错误源于您的设置行:

ACCOUNT_USERNAME_VALIDATORS = 'some.module.validators.custom_username_validators'

您的项目结构中没有模块 some,因此未找到。