2016-10-06 2 views
0

Я реализую пароль пользователя сбрасывается с помощью представлений Джанго, и я получаю ошибку с django.contrib.auth.views.password_reset_confirmошибка django.contrib.auth.views.password_reset_confirm Джанго во время рендеринга шаблона

Ссылки сбросить пароль приходит по электронной почте:

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: [email protected] 
To: [email protected] 
Date: Thu, 06 Oct 2016 19:01:30 -0000 
Message-ID: <[email protected]> 


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 

Когда я по ссылке я получил следующую ошибку:

TypeError на/счета/паролем сброса/подтверждения/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 

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 %} 

ответ

1

Похоже, у вас есть недопустимое AUTH_PASSWORD_VALIDATORS настройки. Это должен быть список словарей. Сообщение об ошибке предполагает, что у вас есть список строк.

Пример, приведенный in the docs является:

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', 
    }, 
] 
+0

Спасибо, я понял, прежде чем увидеть ваш anwser, но вы получили прямо на точку! –