简体   繁体   English

模板渲染期间Django django.contrib.auth.views.password_reset_confirm错误

[英]Django django.contrib.auth.views.password_reset_confirm error during template rendering

I am implementing a user password reset using django views and I am getting some error with django.contrib.auth.views.password_reset_confirm 我正在使用django视图实现用户密码重置,并且django.contrib.auth.views.password_reset_confirm出现了一些错误

The link to reset the password comes through e-mail : 重置密码的链接通过电子邮件发送:

MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on 127.0.0.1:8000
From: webmaster@localhost
To: progpyftk@yahoo.com
Date: Thu, 06 Oct 2016 19:01:30 -0000
Message-ID: <20161006190130.10100.76186@PEAMV57.exprogroup.local>


You're receiving this email because you requested a password reset for your user
 account at 127.0.0.1:8000.

Please go to the following page and choose a new password:

http://127.0.0.1:8000/account/password-reset/confirm/Mw/4fx-63795155cddbbad87a79
/

Your username, in case you've forgotten: Gileno

Thanks for using our site!

The 127.0.0.1:8000 team

When I follow the link I got the following error: 当我点击链接时,出现以下错误:

TypeError at /account/password-reset/confirm/Mg/4fx-ee6f1fadc877a2279bdc/ string indices must be integers / account / password-reset / confirm / Mg / 4fx-ee6f1fadc877a2279bdc /处的字符串错误必须为整数

   return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
  File "C:\Python34\lib\site-packages\django\contrib\auth\password_validation.py
", line 29, in get_password_validators
    klass = import_string(validator['NAME'])
TypeError: string indices must be integers
[06/Oct/2016 16:02:59] "GET /account/password-reset/confirm/Mw/4fx-63795155cddbb
ad87a79/ HTTP/1.1" 500 201517

the password_reset_confirm.html password_reset_confirm.html

{% extends "account/base.html" %}
{% block title %}Reset your password{% endblock %}
{% block content %}
    <h1>Reset your password</h1>
    <!-- We check if the provided link is valid. Django reset password view sets this variable
and puts it in the context of this template. If the link is valid, we display the user
password reset form. -->
    {% if validlink %}
        <p>Please enter your new password twice:</p>
        <form action="." method="post">
            {{ form.as_p }}
            {% csrf_token %}
            <p><input type="submit" value="Change my password"/></p>
        </form>
    {% else %}
            <p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
    {% endif %}
{% endblock %}

It looks like you have an invalid AUTH_PASSWORD_VALIDATORS setting. 看来您的AUTH_PASSWORD_VALIDATORS设置无效。 It should be a list of dictionaries. 它应该是词典列表。 The error message suggests you have a list of strings instead. 该错误信息表明您有一个字符串列表。

The example given in the docs is: 在文档中给出的示例是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于django.contrib.auth.views.password_reset_confirm,Django没有反向 - Django no reverse for django.contrib.auth.views.password_reset_confirm 路径已弃用(django.contrib.auth.views.password_reset_confirm) - path is deprecated (django.contrib.auth.views.password_reset_confirm) NoReverseMatch:反向为``django.contrib.auth.views.password_reset_confirm&#39;&#39; - NoReverseMatch: Reverse for ''django.contrib.auth.views.password_reset_confirm'' 为什么django 1.6在contrib.auth.views.password_reset_confirm视图上将“ form”设置为“ none”? - Why is django 1.6 setting “form” to “none” on the contrib.auth.views.password_reset_confirm view? “AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset'” urls.py 中的错误 - “AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' ” error in urls.py django.contrib.auth视图和模板变量 - django.contrib.auth views and template vars password_reset行185中的&#39;str&#39;对象不可调用/django/contrib/auth/views.py - 'str' object is not callable /django/contrib/auth/views.py in password_reset, line 185 Django Auth查看密码重置URL - Django Auth Views Password Reset URL 贡献验证重置密码错误 - Contrib Auth Reset Password Error Django密码重置确认 - Django password reset confirm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM