Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the subject for Django error reporting emails?

Tags:

python

django

i noticed about to change the subject for django error reporting emails, is it possible to change subject? can we modify the subject for Django error reporting emails ?

like image 855
swamy_venkatesh Avatar asked Apr 24 '15 05:04

swamy_venkatesh


2 Answers

You need to set the EMAIL_SUBJECT_PREFIX variable in your Django settings file.

https://docs.djangoproject.com/en/1.8/ref/settings/#email-subject-prefix

EMAIL_SUBJECT_PREFIX

Default: '[Django] '

Subject-line prefix for email messages sent with django.core.mail.mail_admins or django.core.mail.mail_managers. You’ll probably want to include the trailing space.

If you don't like Django error emails and want a better way of handling them, take a look a Sentry.

like image 72
alejandrodnm Avatar answered Sep 24 '22 04:09

alejandrodnm


If you need it only for reporting errors the best choice would be to inherit from the django.utils.log.AdminEmailHandler and override the def format_subject(self, subject): method.

Note that changing EMAIL_SUBJECT_PREFIX will affect not only error emails but all emails send to admins including system information emails or so.

like image 27
Rafał Maciejczyk Avatar answered Sep 20 '22 04:09

Rafał Maciejczyk