Hello Awesome People!
Before my question, I tried these SO posts:
None of them works!
I want to keep users on a website update with new courses. With a queryset of Courses, I want to send them via email.
send_daemon_email.delay(instance=instance,all_courses=Course.objects.all())
And my function looks like:
@shared_task
def send_daemon_email(instance,all_courses):
ctx = {'instance':instance,'all_courses':all_courses}
message = get_template("emails/ads.html").render(ctx)
''' '''
When I tried to send the email to a specific user The error I got is
<User: First Name> is not JSON serializable
Just because delay() from celery got a non serialized data.
How I can send Django objects to celery task so I can use it in the template? I know that I can send information needed as python object
send_daemon_email.delay(first_name='Name',
last_name='Lapr',all_courses = [{'title1':'title1',},{'title2':'title2',}])
but it would be too much info.
Any hint will be appreciated. Thank you!
pk, I can retrieve the object within the function? that's a good point