pmclanahan/django-celery-email

Documentation: Add pickle serializer requirement

andresriancho opened this issue · 2 comments

Add documentation text explaining that this module only works if the CELERY_TASK_SERIALIZER is pickle. Otherwise the pickling of email messages fails:

>>> from django.core.mail import EmailMessage
>>> e = EmailMessage('a', 'b', 'c@d.com')
>>> import json
>>> json.dumps(e)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 201, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 264, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 178, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <django.core.mail.message.EmailMessage object at 0x3f95c10> is not JSON serializable
>>> 

Or even better, merge these changes where it is fixed