Created
July 30, 2013 19:33
-
-
Save laat/6116124 to your computer and use it in GitHub Desktop.
Enkel rendring av *text* templates med django. dvs, ikke html.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding=utf-8 | |
from django.core.mail import send_mail as djsend_mail | |
from django.template.loader import get_template | |
from django.template import Context | |
#>>> util.send_mail('events/index.html', "lol", "fra", "til", {'events': "dette er events"}) | |
def send_mail(template, subject, fra , to, context): | |
if(isinstance(to, str)): # to can be both a list of strings or a string. | |
to = [to] | |
body = get_template(template).render(Context(context)) | |
djsend_mail(subject, body, fra, to) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment