标签云

微信群

扫码加入我们

WeChat QR Code

I'm trying to get the django password reset working but the reset email does not get sent.I know my email is properly configured because the following works both in the shell and in one of my views (I'm using it to get support email to myself).from django.core.mail import send_mailsend_mail('Subject here', 'Here is the message.','[email protected]',['[email protected]'], fail_silently=False)I can get to my reset password view (password/reset/) and after I give it my email it correctly redirects me to password/reset/done/ but it doesn't sends the email.Here's my urls.py:(r'^password/reset/$','django.contrib.auth.views.password_reset'),(r'^password/reset/done/$','django.contrib.auth.views.password_reset_done'),(r'^password/reset/confirm/$','django.contrib.auth.views.password_reset_confirm'),(r'^password/reset/complete/$','django.contrib.auth.views.password_reset_confirm'),(r'^password/change/$','django.contrib.auth.views.password_change'),(r'^password/change/done/$','django.contrib.auth.views.password_change_done'),Here's my password_reset_form.html:<html><head><link rel="stylesheet" type="text/css" href="/media/css/style_login.css" /><title>Información de acceso requerida</title></head><body><div id="wrapper"><h1>Recuperar password</h1><p>Utilice este formulario cuando desee recuperar el password para su usuario.</p>{% if form.errors %}<p>No hay un usuario registrado con ese correo electronico.</p>{% endif %}<form method="post" action="{% url django.contrib.auth.views.password_reset_done %}">{% csrf_token %}{{ form }}<input class="login" type="submit" value="Recuperar" /></form></div></body>Any ideas? Thanks


Please turn your comment into a real answer below. You can mark it as accepted after two days. That will make the question go away from the Unanswered Questions tab.

2019年08月26日05分23秒

Cool, I'm new to the community and that kind of tips are really helpful :)

2019年08月26日05分23秒

You're welcome, thanks a lot for coming back and helping us clean up!

2019年08月26日05分23秒

I had the same issue, the missing value is DEFAULT_FROM_EMAIL. If that is not set, the email won't send.

2019年08月26日05分23秒

not working in django 2.1.7 :(

2019年08月26日05分23秒

Thanks, I have been pulling out my hair for hours trying to figure this out.Btw, there is password = User.objects.make_random_password()

2019年08月26日05分23秒

Thanks! FYI neither os.urandom() or make_random_password() worked for me, I used:from django.contrib.auth.hashers import make_password password = make_password(User.objects.make_random_password())

2019年08月26日05分23秒

Anyone thinking or doing this should stop IMMEDIAGTELY and create custom forms to allow users to signup.if you want to do stuff like admin approval, email varification, or the like... use django-registration.readthedocs.io/en

2019年08月26日05分23秒