From 4099c748724e08cd27bf791905c5a022d3faac35 Mon Sep 17 00:00:00 2001 From: Giovanni Bottalico Date: Wed, 13 Oct 2021 19:47:51 +0200 Subject: [PATCH] support "content_subtype" EmailMultiAlternatives when use dict in serialization --- django_q_email/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/django_q_email/utils.py b/django_q_email/utils.py index c2f8ce8..cbb8111 100644 --- a/django_q_email/utils.py +++ b/django_q_email/utils.py @@ -20,6 +20,7 @@ def to_dict(email_message): } if isinstance(email_message, EmailMultiAlternatives): email_message_data['alternatives'] = email_message.alternatives + email_message_data['content_subtype'] = getattr(email_message, 'content_subtype', None) return email_message_data @@ -30,6 +31,10 @@ def from_dict(email_message_data): """ kwargs = dict(email_message_data) alternatives = kwargs.pop('alternatives', None) - return ( + content_subtype = kwargs.pop('content_subtype', None) + email = ( EmailMessage(**kwargs) if not alternatives else EmailMultiAlternatives(alternatives=alternatives, **kwargs)) + if content_subtype: + email.content_subtype = content_subtype + return email