send mail to user for password_reset

允我心安 提交于 2019-12-13 08:36:55

问题


I am trying to implement password_reset (message sending to user for reset his password), but after writing email, nothing has send and the user is redirected to home...

My view.py :

...

from django.contrib.auth.views import password_reset, password_reset_confirm

# Import the render shortcut to render the templates in response.
from django.shortcuts import render

# This view handles the password reset form URL /.
def reset(request):
    return password_reset(request, template_name='le_site/reset.html',
    email_template_name='le_site/password_reset_email.html',
    subject_template_name='le_site/mdp-oublie_texte.txt ',
    post_reset_redirect=reverse('success'))

# This view handles password reset confirmation links. See urls.py file for the mapping.
# This view is not used here because the password reset emails with confirmation links
# cannot be sent from this application.
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(request, template_name='le_site/password_reset_confirm.html',
    uidb36=uidb36, token=token, post_reset_redirect=reverse('success'))

# This view renders a page with success message.
def success(request):
  return render(request, "le_site/password_reset_complete.html")

...

My urls.py :

from mysite.views import reset
...
url(r'reset$', 'reset', name='reset'), 
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        'reset_confirm', name='password_reset_confirm'),
url(r'^success/$', 'success', name='success'),
...

I know it's not important but I write directly http://localhost:8000/reset for access to the reset form page.

Why It doesn't works ? :( Why nothing is sent ? Why I am redirect to home page ?

Thank's

来源:https://stackoverflow.com/questions/33702434/send-mail-to-user-for-password-reset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!