im using django-registration, all is fine, the confirmation email was sending in plain text, but know im fixed and is sending in html, but i have a litter problem... the html code is showing:
<a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/">http://www. example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/</a>
and i dont need to show the html code like the ...
Any idea?
Thanks
Then we used the EmailMessage() function to send mail along with the subject, message. Email message create by a template. This template create an email body with activate link that will send for application. Now we need to create a view for the activation link.
I'd recommend sending both a text version and an html version. Look in the models.py of the django-registration for :
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [self.user.email])
and instead do something like from the docs http://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types
from django.core.mail import EmailMultiAlternatives
subject, from_email, to = 'hello', '[email protected]', '[email protected]'
text_content = 'This is an important message.'
html_content = '<p>This is an <strong>important</strong> message.</p>'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
I know this is old and the registration package is no longer maintained. Just in case somebody still wants this.
The additional steps wrt to the answer of @bpierre are:
- subclass the RegistrationView, i.e. your app's views.py
class MyRegistrationView(RegistrationView):
...
def register(self, request, **cleaned_data):
...
new_user = HtmlRegistrationProfile.objects.create_inactive_user(username, email, password, site)
- in your urls.py change the view to the sub-classed view, i.e. - List item
url(r'accounts/register/$', MyRegistrationView.as_view(form_class=RegistrationForm), name='registration_register'),'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With