2👍
✅
You’re getting the error as expected. Celery is setup to use JSON serialization and is using the built in json
library that attempts to serialize django.core.mail
which obviously doesn’t support any form of serialization.
The reason it works when calling without delay
is because it works like calling a typical function (in the same process).
If you have to return something from a task, you can return a dictionary of values or objects that support serialization. For custom serializations, you can use the serializer
property and pass your custom decoder/encoder when calling the task.
In your case you can return something like {'success': True}
and False value for any failures.
More options on using custom serializers
Source:stackexchange.com