def notify(self, event, id_list): from wsrc.site.usermodel.models import Player players = [Player.objects.get(pk=id) for id in id_list] contact_details = [["Name", "E-Mail", "Mobile Phone", "Other Phone"]] for player in players: contact_details.append( [player.user.get_full_name(), player.user.email, player.cell_phone, player.other_phone] ) context = Context( { "event": event, "content_type": "text/html", "notified_members": players, "contact_details_table": text_utils.formatTable(contact_details, True), } ) subject = "Court Cancellation" from_address = "*****@*****.**" html_body = markdown.markdown(self.email_template.render(context)) context["content_type"] = "text/plain" text_body = self.email_template.render(context) to_list = [p.user.email for p in players if "@" in p.user.email] LOGGER.debug("sending email to {0}".format(to_list)) try: self.send_email(subject, text_body, html_body, from_address, to_list) except: import traceback traceback.print_exc()