我需要显示在Django admin中创建新用户时输入的密码是强还是弱。请通过建议如何做到这一点来帮助我。任何帮助都会被暗示
class NewForm(forms.Form):
email = forms.EmailField()
password = forms.CharField(widget=forms.PasswordInput())
confirm_password = forms.CharField(widget=forms.PasswordInput())
def clean_new_password1(self):
password1 = self.cleaned_data.get('password')
if len(password1) < 6:
"display password is weak on successfully submission of form"
else:
"display password is strong on successfully submission of form"
return True
答案 0 :(得分:1)
我会使用Django中包含的messaging framework来执行此操作。我还没有乐意修补它,但它看起来确实适合这项工作。
虽然它没有直接回答你的问题,但你也可以尝试this module对我来说看起来很漂亮,但可能不是你正在寻找的。 p >