I've cloned parts of django-registration into my project. Specifically, the RegistrationProfile bit for activation_key generation, user activation, and verification email sending.
I've replaced the native send_email bit with a EmailMultiAlternatives version to send HTML Emails.
It look something like this:
def send_activation_email(self, site):
context = {
'link': (site+"signup/activate/"+self.activation_key),
'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
'site': site
}
# SUBJECT
subject = render_to_string(
'registration/activation_email_subject.txt',
context
)
subject = ''.join(subject.splitlines())
# BODY
html_content = render_to_string(
'registration/activation_email.html',
context
)
text_content = strip_tags(html_content)
# MESSAGE
message = EmailMultiAlternatives(
subject,
text_content,
settings.DEFAULT_FROM_EMAIL,
[self.user.email]
)
message.attach_alternative(html_content, "text/html")
I can print the link with {{link}} in the template. How can I use the link as an href attribute if I wanted something like <a href={{link}}>Activate</a> (or a button)?
<a href='{{link}}'>Activate</a>work (note quotes)? If I'm correctly understanding the question.<a></a>tag turn up empty.