In my application i'm using the built-in auth views. I'm also using a postmark connection using django-anymail for some user email notifications.
Example:
email_backend = get_connection('anymail.backends.postmark.EmailBackend')
mail = EmailMessage(
subject=subject,
body=message,
to=[settings.DEFAULT_FROM_EMAIL],
connection=email_backend
)
I want to change the connection i'm sending email with in PasswordResetView. Is there any way i can give a keyword argument in the PasswordResetView.as_view() the same way i'm giving html_email_template_name='...' or success_url='...'? or do i have to rewrite PasswordResetView?
You don't have to change the
PasswordResetView, but you will have to create a customPasswordResetFormthat you can then pass as a keyword argument toPasswordResetView.as_view().If you look at the source code of
PasswordResetView, you will see that it doesn't actually send the email itself. The email sending is done as part ofPasswordResetForm.save(), which callsPasswordResetForm.send_mail()You could subclass
PasswordResetFormand overwrite.send_mail()to use your custom email backend: