Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在django allauth中设置用户密码的最小字符数_Python_Django_Django Allauth - Fatal编程技术网

Python 如何在django allauth中设置用户密码的最小字符数

Python 如何在django allauth中设置用户密码的最小字符数,python,django,django-allauth,Python,Django,Django Allauth,我想更改django allauth中的帐户\密码\最小\长度。我在settings.py中尝试了ACCOUNT\u PASSWORD\u MIN\u LENGTH=5,但它不起作用,Django仍然说我需要输入8个字符,就像默认情况一样 这是我的settings.py文件: # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django

我想更改django allauth中的帐户\密码\最小\长度。我在settings.py中尝试了ACCOUNT\u PASSWORD\u MIN\u LENGTH=5,但它不起作用,Django仍然说我需要输入8个字符,就像默认情况一样

这是我的settings.py文件:

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'taggit',
    'django_summernote',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'user_account',
    'widget_tweaks',

]

SITE_ID = 1

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 = 'project_blog.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 = 'project_blog.wsgi.application'


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

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


# Password validation
# https://docs.djangoproject.com/en/1.10/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',
    },
]

# Django-allauth
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',
)

# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    #'/var/www/static/',
]

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn')

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


SUMMERNOTE_CONFIG = {
    # Using SummernoteWidget - iframe mode
    'iframe': True,  # or set False to use SummernoteInplaceWidget - no iframe mode

    # Using Summernote Air-mode
    'airMode': False,

    # Use native HTML tags (`<b>`, `<i>`, ...) instead of style attributes
    # (Firefox, Chrome only)
    'styleWithTags': True,

    # Set text direction : 'left to right' is default.
    'direction': 'ltr',

    # Change editor size
    'width': '100%',
    'height': '480',

    # Authentication required
    'attachment_require_authentication': False,
}

EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'

# Custom allauth settings
# Use email as the primary identifier
ACCOUNT_AUTHENTICATION_METHOD = 'email' 
ACCOUNT_EMAIL_REQUIRED = True
# Make email verification mandatory to avoid junk email accounts
ACCOUNT_EMAIL_VERIFICATION = 'mandatory' 
# Eliminate need to provide username, as it's a very old practice
ACCOUNT_USERNAME_REQUIRED = False
# Minimum password characters
ACCOUNT_PASSWORD_MIN_LENGTH = 5
#应用程序定义
已安装的应用程序=[
“django.contrib.admin”,
“django.contrib.auth”,
“django.contrib.contenttypes”,
“django.contrib.sessions”,
“django.contrib.messages”,
“django.contrib.staticfiles”,
“博客”,
“塔吉特”,
“django_summernote”,
“django.contrib.sites”,
“阿拉斯”,
“allauth.账户”,
“allauth.socialaccount”,
“用户帐户”,
“widget_调整”,
]
站点ID=1
中间件=[
'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.xFrameOptions中间件',
]
ROOT_URLCONF='project_blog.url'
模板=[
{
'BACKEND':'django.template.backends.django.DjangoTemplates',
'DIRS':[os.path.join(BASE_DIR,'templates'),
“应用程序目录”:正确,
“选项”:{
“上下文处理器”:[
“django.template.context_processors.debug”,
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_应用程序='project_blog.WSGI.APPLICATION'
#数据库
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
数据库={
“默认值”:{
“引擎”:“django.db.backends.sqlite3”,
'NAME':os.path.join(BASE_DIR'db.sqlite3'),
}
}
#密码验证
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-密码验证器
验证密码验证程序=[
{
'NAME':'django.contrib.auth.password\u validation.UserAttributesMilarityValidator',
},
{
'NAME':'django.contrib.auth.password\u validation.MinimumLengthValidator',
},
{
'NAME':'django.contrib.auth.password\u validation.CommonPasswordValidator',
},
{
'NAME':'django.contrib.auth.password\u validation.NumericPasswordValidator',
},
]
#Django allauth
身份验证\u后端=(
#需要在Django admin中通过用户名登录,而不管'allauth'`
'django.contrib.auth.backends.ModelBackend',
#`allauth`特定的身份验证方法,如通过电子邮件登录
'allauth.account.auth_backends.AuthenticationBackend',
)
#国际化
# https://docs.djangoproject.com/en/1.10/topics/i18n/
语言代码='en us'
时区='UTC'
使用_I18N=True
使用\u L10N=True
使用_TZ=True
#静态文件(CSS、JavaScript、图像)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
静态URL='/STATIC/'
静态文件\u目录=[
join(BASE_DIR,'static'),
#“/var/www/static/”,
]
STATIC\u ROOT=os.path.join(os.path.dirname(BASE\u DIR),'STATIC\u cdn')
媒体URL='/MEDIA/'
MEDIA\u ROOT=os.path.join(os.path.dirname(BASE\u DIR),'MEDIA\u cdn')
SUMMERNOTE_配置={
#使用SummernoteWidget-iframe模式
“iframe”:True、#或设置False以使用SummernoteInplaceWidget-无iframe模式
#使用Summernote空气模式
“airMode”:False,
#使用本机HTML标记(``、``、…)而不是样式属性
#(仅限Firefox、Chrome)
“styleWithTags”:True,
#设置文本方向:“从左到右”是默认值。
“方向”:“ltr”,
#更改编辑器大小
“宽度”:“100%”,
“高度”:“480”,
#需要身份验证
“附件\u需要\u身份验证”:False,
}
EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'
#自定义allauth设置
#使用电子邮件作为主要标识符
帐户\身份验证\方法='电子邮件'
帐户\电子邮件\必需=真
#强制电子邮件验证以避免垃圾邮件帐户
帐户\电子邮件\验证='强制'
#不再需要提供用户名,因为这是一种非常古老的做法
帐户\用户名\必需=False
#最小密码字符数
帐户\密码\最小\长度=5
根据,您需要指定
选项
dict和内置django密码验证器,如下所示:

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'OPTIONS': {
            'min_length': 5,
        },
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

帐户\密码\最小\长度为。使用Django自己的身份验证密码验证程序设置