def send_template_sms(sender, receiver, template_name, context, autosave=True): message = Message() message.method = Message.SMS message.sender = sender message.receiver = receiver context['sender_address'] = sender context['receiver_address'] = receiver context.update(site_url(None)) content = render_to_string(template_name, context).strip() message.content = content if autosave: message.save() return message