2
votes

i am using Django Build in

PasswordResetView class.

i am using Django File backend in settings. i tried to reset password of an existing account and django returns a success but still no email is sent. Here is code for reference:

settings.py

 EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = os.path.join(BASE_DIR,'sent_emails')

views.py

class MyPasswordReset(PasswordResetView):
email_template_name = 'email/forgot_password.html'
form_class = ForgotPassword
from_email = '[email protected]'
success_url = reverse_lazy('users:password_reset_done')

form.py

class ForgotPassword(PasswordResetForm):
email = forms.EmailField(widget=forms.EmailInput(attrs=
                            {'class': 'form-control', 'title': 'Enter Email', 'placeholder': 'Email'}),
                         max_length=50, label=False, required=True,
                         )

Password Reset Email Template

email/forgot_password.html

you forgot your password!! Sample Email

Code for Complete reference: https://github.com/deepak1725/basicCrud/tree/dk-signup/users

1
have you configured the email settings?Exprator
@Exprator all i did in settings.py is as i mentioned. what else needed..?Deepak Sharma
an email server to send the emails, which you need to mention the settings.pyExprator
@Exprator i am at local.. using file backend. Expected behavior is make *.log files in my folder sent_emails with email content in it.Deepak Sharma

1 Answers

5
votes

After deep analysing i figured out, i was storing email in username's field in auth User table.

Hence on using built in reset password view , it queries by database on email field, and hence the email field is found empty. So, the result returned is null and therefore no email sending is processed.