This middleware makes the admin error emails a lot more informative: you get the same HTML response that you get with
It uses the base class defined in #638.
You will probably want to apply the patch for #6748 to help avoid slowdowns caused by unintentional database queries. As the ticket (and django-developers thread) notes, it isn't foolproof; you may still find this executing database queries.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
from exception_middleware import import StandardExceptionMiddleware, _get_traceback from django.conf import settings from django.core.mail import EmailMultiAlternatives class HTMLMailExceptionMiddleware(StandardExceptionMiddleware): def log_exception(self, request, exception, exc_info): debug_response = self.debug_500_response(request, exception, exc_info) subject, message = self.exception_email(request, exc_info) msg = EmailMultiAlternatives(settings.EMAIL_SUBJECT_PREFIX + subject, message, settings.SERVER_EMAIL, [a for a in settings.ADMINS]) msg.attach_alternative(debug_response.content, 'text/html') msg.send(fail_silently=True)
More like this
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 3 weeks, 4 days ago
- Python Django CRUD Example Tutorial by tuts_station 1 month, 1 week ago
- Browser-native date input field by kytta 2 months, 3 weeks ago
- Generate and render HTML Table by LLyaudet 3 months ago
- My firs Snippets by GutemaG 3 months, 1 week ago