django-password-strength“米”没有更新

时间:2017-02-14 01:19:03

标签: django django-forms django-templates

我正在尝试使用django-password-strength库实现密码强度“meter”:https://github.com/noodlecake/nc-django-password-strength。强度计能够在我的change_password.html模板中呈现,但在密码字段中输入内容时不会更新。有没有人有任何在他们的Django项目中实现这一点的经验?任何帮助,将不胜感激。这是我的仓库的链接:https://github.com/brianweber2/project7_user_profile_with_django。以下是感兴趣的主要文件。

谢谢!

forms.py

class ValidatingPasswordChangeForm(PasswordChangeForm):
    """Form for changing user's password."""
    MIN_LENGTH = 14

    class Media:
        js = (
            'js/zxcvbn.js',
            'js/password-strength.js'
        )

    new_password1 = forms.CharField(
        widget=PasswordStrengthInput(attrs={'placeholder': 'New password'}),
        label='New Password'
    )
    new_password2 = forms.CharField(
        widget=PasswordConfirmationInput(
            attrs={'placeholder': 'Confirm new password'},
            confirm_with='new_password1'
        ),
        label='Confirm Password'
    )

change_password.html

{% extends 'layout.html' %}
{% load static from staticfiles %}
{% load bootstrap3 %}

{% block title %}
    {{ block.super }} - Change Password
{% endblock %}

{% block header %}
    {{ form.media }}
{% endblock %}

{% block body %}
    <div class="form-container" style="max-width: 500px; margin: 0 auto;">
        <h1>Change Password</h1>
        <form method="POST">
            {% csrf_token %}
            {% bootstrap_form form %}
            <input type="submit" value="Change Password" class="button">
        </form>
    </div>
{% endblock %}

settings.py

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'assets'),
]

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

0 个答案:

没有答案