提问人:ungali 提问时间:8/17/2023 更新时间:8/17/2023 访问量:37
Improperty在 django 中配置了自定义密码值管理器的问题
ImpropertyConfigured issues with customized password valiators in django
问:
我正在为 django 编写自定义密码验证器。但是我收到 InproperlyConfigured 错误 ->
配置不当 django.core.exceptions.ImproperlyConfigured:无法导入 NAME 中的模块:auth.validators.UppercaseValidator。检查您的AUTH_PASSWORD_VALIDATORS设置。
settings.py(路径:app/conf/settings/settings.py)。->
AUTH_PASSWORD_VALIDATORS = [
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'OPTIONS': {'min_length': 12}},
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
{'NAME': 'auth.validators.UppercaseValidator'},
]
validators.py(路径:app/auth/validators.py)。->
import re
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
class UppercaseValidator(object):
def validate(self, password, user=None):
if not re.findall('[A-Z]', password):
raise ValidationError(
_("The password must contain at least 1 uppercase letter, A-Z."),
code='password_no_upper',
)
def get_help_text(self):
return _("Your password must contain at least 1 uppercase letter, A-Z.")
我开始有点疯狂,因为我看不出问题出在哪里 Priz帮帮我
答: 暂无答案
评论
auth
custom_auth
if not re.findall('[A-Z]', password):
if not len(re.findall('[A-Z]', password)) >= 1:
'app.auth.validators.UppercaseValidator'