Manually trigger Django email error report

You can use the following code to send manually an email about a request and an exception e: import sys import traceback from django.core import mail from django.views.debug import ExceptionReporter def send_manually_exception_email(request, e): exc_info = sys.exc_info() reporter = ExceptionReporter(request, is_email=True, *exc_info) subject = e.message.replace(‘\n’, ‘\\n’).replace(‘\r’, ‘\\r’)[:989] message = “%s\n\n%s” % ( ‘\n’.join(traceback.format_exception(*exc_info)), reporter.filter.get_request_repr(request) ) mail.mail_admins( … Read more

Creating email templates with Django

From the docs, to send HTML e-mail you want to use alternative content-types, like this: from django.core.mail import EmailMultiAlternatives subject, from_email, to = ‘hello’, ‘from@example.com’, ‘to@example.com’ text_content=”This is an important message.” html_content=”<p>This is an <strong>important</strong> message.</p>” msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, “text/html”) msg.send() You’ll probably want two templates for your e-mail – a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)