Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a hash to the generated error emails on Django
    text
    copied!<p>We have a web application that sends out emails on server errors like <a href="https://docs.djangoproject.com/en/dev/howto/error-reporting/#server-errors" rel="nofollow">django specifies</a>. We need to attach a hash to each email, though, so that we can better manage them.</p> <p>Unfortunately, the majority of the documentation that discusses reformatting these emails is for version 1.3. We use 1.2.7, and can't upgrade. It seems like this means that the <a href="https://docs.djangoproject.com/en/dev/topics/logging/#an-example" rel="nofollow">dictConfig()</a> examples don't apply to us.</p> <p>I have found this method of patching django:</p> <pre><code>diff --git a/django/django/core/handlers/base.py b/django/django/core/handlers/base.py index 45f8445..1605549 100644 --- a/django/django/core/handlers/base.py +++ b/django/django/core/handlers/base.py @@ -1,4 +1,4 @@ -import sys +import sys, md5 from django import http from django.core import signals @@ -170,7 +170,11 @@ class BaseHandler(object): request_repr = repr(request) except: request_repr = "Request repr() unavailable" - message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) + tb=self._get_traceback(exc_info) + # generate an md5 hash from this as a fingerprint + hash=md5.new(tb) + fingerprint='fingerprint: %s' % hash.hexdigest() + message = "%s\n\n%s\n\n%s" % (tb, fingerprint, request_repr) mail_admins(subject, message, fail_silently=True) # If Http500 handler is not installed, re-raise last exception if resolver.urlconf_module is None: </code></pre> <p>Unfortunately this patch has to be re-applied each time we upgrade django.</p> <p>What's the best way to customize emails in django 1.2?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload