I am learning Celery. In my website, I let people register an account. Once they create a new account, it will automatically send an activation email to their user email address
Celery need to serialize the arguments for a task. Here, user is not serializable, but you can replace it with its ID:
In tasks.py:
from __future__ import absolute_import
from celery.decorators import task
from django.contrib.auth import get_user_model
@task()
def user_send_activation_email(user_id):
user = get_user_model().objects.get(pk=user_id)
user.send_activation_email()
Then call it from views.py using:
user_send_activation_email.delay(user_id=user.pk)