django-mail-templated icon indicating copy to clipboard operation
django-mail-templated copied to clipboard

Raise nice error if not inheriting from the base template

Open jonashaag opened this issue 9 years ago • 1 comments

If I forget to inherit from the base template provided with django-mail-templated, I'll get some cryptic error like this:

Traceback (most recent call last):
  File "mail_templated/message.py", line 227, in send
    return super(EmailMessage, self).send(*args, **kwargs)
  File "django/core/mail/message.py", line 292, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "django/core/mail/backends/locmem.py", line 26, in send_messages
    message.message()
  File "django/core/mail/message.py", line 255, in message
    msg = SafeMIMEText(self.body, self.content_subtype, encoding)
  File "django/core/mail/message.py", line 171, in __init__
    MIMEText.__init__(self, _text, _subtype, None)
  File "email/mime/text.py", line 34, in __init__
    _text.encode('us-ascii')
AttributeError: 'NoneType' object has no attribute 'encode'

This should be caught earlier if possible and turned into a nice error message.

jonashaag avatar Feb 21 '16 22:02 jonashaag

Thanks for the note. This definitely should be implemented.

artemrizhov avatar Feb 22 '16 00:02 artemrizhov