macropin / django-registration

Django-registration (redux) provides user registration functionality for Django websites.
http://django-registration-redux.readthedocs.org
Other
974 stars 348 forks source link

Add support for sending email with html content when password change #275

Closed KomeijiSatori closed 7 years ago

KomeijiSatori commented 7 years ago

It seems that for now when change the password, the confirm email is sent with plain text rather than html. From the official document here, the default method won't send html email. So can you override the origin method in the next release? Thank you very much for your effort.

joshblum commented 7 years ago

@KomeijiSatori Would you be able to submit a PR to handle this? It should be relatively simple to add the template for https://github.com/macropin/django-registration/blob/master/registration/templates/registration/password_reset_email.html to the view

KomeijiSatori commented 7 years ago

@joshblum Do you mean I can extends the PasswordResetView and set the html_email_template_name field to the template name? And what about Django <= 1.10? So should I create a new method to call the password_reset method with parameter html_email_template_name be set?

joshblum commented 7 years ago

You can pass in a kwarg to the call to as_view for the PasswordResetView and for Django <= 1.10 you can pass in the template name as follows:

        url(r'^password/reset/$',
            auth_views.password_reset,
            {'post_reset_redirect': reverse_lazy('auth_password_reset_done'),
               'html_email_template_name': 'registration/password_reset_email.html',
              }, name='auth_password_reset'),

Although on second thought it might be best to leave the Django defaults in the library and to include the html template in your local installation (You can choose to not include the default auth urls and put your own custom ones in.) I'll defer to @dicato or @macropin for what to do with the library.

KomeijiSatori commented 7 years ago

Cool, It seems to work. In that way developers can write their own urls or overwrite the default urls to meet their needs. But it seems not friendly to new developers who don't know the trick, since refer to the official doc is kind of time consuming. It will be better to set a flag in settings whether password_reset_email should be html. Thank you very much for helping me!

joshblum commented 7 years ago

Instead of a settings flag, do you want to submit a PR that adds an example to the docs for future developers to use?

KomeijiSatori commented 7 years ago

That's OK, but which file should I add examples to?

joshblum commented 7 years ago

FAQ might be best On Fri, Jul 28, 2017 at 10:52 Satori notifications@github.com wrote:

That's OK, but which file should I add examples to?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/macropin/django-registration/issues/275#issuecomment-318673295, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF01EX4YLS2PRE4xpkKYSK3ifduLWqVks5sSfWygaJpZM4Oil7P .

KomeijiSatori commented 7 years ago

OK, but it seems I don't have permission to create a pull request

joshblum commented 7 years ago

@KomeijiSatori this should help! https://help.github.com/articles/creating-a-pull-request-from-a-fork/ let me know if you run into any issues

joshblum commented 7 years ago

closed by #276