python - How to set minimum number of characters for user password in django-allauth -
i want change account_password_min_length in django-allauth. tried account_password_min_length = 5 in settings.py , not working, django still saying need enter 8 characters, default.
here settings.py file:
# 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 login username in django admin, regardless of `allauth` 'django.contrib.auth.backends.modelbackend', # `allauth` specific authentication methods, such login 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 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 right' 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 primary identifier account_authentication_method = 'email' account_email_required = true # make email verification mandatory avoid junk email accounts account_email_verification = 'mandatory' # eliminate need provide username, it's old practice account_username_required = false # minimum password characters account_password_min_length = 5
according django docs, need specify options
dict built in django password validator, this:
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', }, ]
Comments
Post a Comment