gpt4 book ai didi

passwords - Django : Reverse for 'password_reset_complete' not found

转载 作者:行者123 更新时间:2023-12-03 08:18:50 41 4
gpt4 key购买 nike

我正在尝试使用 Django 内置 View 来重置密码,但最终出现错误。我已经完成了以下步骤:
1. 在 URLs.py 中:

url(r'^password_reset/$', auth_views.password_reset,{'email_template_name':'registration/password_reset_email.html','subject_template_name':'registration/password_reset_subject.txt','post_reset_redirect':'main:password_reset_done','from_email':'something@gmail.com',},name='password_reset'),
url(r'^reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',auth_views.PasswordResetConfirmView.as_view(),{'success_url':'passwordresetcomplete'}, name='password_reset_confirm' ),
url(r'^password_reset/done/$', auth_views.password_reset_done, {'template_name': 'registration/password_reset_done.html'}, name='password_reset_done'),
url(r'^reset/confirm/done/$', auth_views.password_reset_complete, name='password_reset_complete'),

我还在 appname/templates/registration/中添加了我的自定义 html 文件,html 文件是:
  • password_reset_complete.html
  • password_reset_email.html
  • password_reset_confirm.html
  • password_reset_form.html
  • password_reset_done.html
  • password_reset_subject.txt

  • 现在是这样:当我去 http://127.0.0.1:8000/password_reset/ 时它要求一个电子邮件地址。为用户输入电子邮件后,它说我们已向您发送了一个链接,我在电子邮件中看到了该链接。当我点击链接时,会打开一个页面并要求输入新密码和密码确认。当我点击提交按钮时,我可以看到密码确实被更改了,但不是被定向到 html 页面,而是出现错误。这里是
    NoReverseMatch at /reset/confirm/MQ/set-password/
    Reverse for 'password_reset_complete' not found. 'password_reset_complete' is not a valid view function or pattern name.
    Request Method: POST
    Request URL: http://127.0.0.1:8000/reset/confirm/MQ/set-password/
    Django Version: 1.11.2
    Exception Type: NoReverseMatch
    Exception Value:
    Reverse for 'password_reset_complete' not found. 'password_reset_complete' is not a valid view function or pattern name.
    Python Version: 2.7.12

    最佳答案

    默认情况下,您遇到错误的链接在您的项目 urls.py 中而不是在 apps:urls.py 中尝试将其放入 project.urls.py 并运行代码

    关于passwords - Django : Reverse for 'password_reset_complete' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45775649/

    41 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com