Send HTML templates with Django


/ Published in: Django
Save to your folder(s)



Copy this code and paste it in your HTML
  1. from django.template import loader, Context
  2.  
  3. t = loader.get_template('registration/email.txt')
  4. c = Context({
  5. 'name': form.cleaned_data['first_name'],
  6. 'website_name': 'Website Name',
  7. 'website_url': 'http://www.yourwebsite.com/',
  8. 'login_url': 'http://www.yourwebsite.com/login/',
  9. 'username': form.cleaned_data['username'],
  10. })
  11.  
  12.  
  13.  
  14. from django.core.mail import send_mail
  15.  
  16. send_mail('Thanks for registering at your website', t.render(c), '[email protected]', [form.cleaned_data['email']], fail_silently=False)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.