Helping Sort Django's Error Emails

When you run a Django powered website with debugging turned off, whenever a condition happens that would cause a HTTP 500 Error (such as an uncaught exception), the administrators receive an e-mail with a traceback and other relevant details to help debug the issue. These e-mails are really, really handy.

If however you run multiple Django sites, all with Debugging turned off, it can become difficult to tell which emails and errors relate to which site.

There are two solutions:

  1. Write perfect code that never throws errors; or
  2. Get Django to prefix the subject of the error e-mails so you can tell what belongs where.

Since there are only 24 hours in a day (most of which when I'm either sleeping or at my non-Django day job which pays the bills) I've opted for #2. And doing that is easy.

All you need to do is set the EMAIL_SUBJECT_PREFIX variable in settings.py:

EMAIL_SUBJECT_PREFIX = '[myproject] '

Easy as pie!


Thanks for reading.

I'd love to hear your feedback and comments. E-mail me, ross@rossp.org, or get in touch on Twitter where I'm @RossPoulton. Chat soon!