Search code examples
pythondjangocelerydjango-celery

How to configure TASK_SERIALIZER with django-celery


I'm using django-celery and I'd like to set the TASK_SERIALIZER to JSON instead of pickle.

I can do this on a per-method basis by changing my task decorators from

@task

to

@task(serializer="json")

But I'd like to do it globally. Setting

TASK_SERIALIZER="json"

in settings.py doesn't work. Trying to run

import celery
celery.conf.TASK_SERIALIZER="json"

(as implied here) results in

AttributeError: 'module' object has no attribute 'conf'

Any idea how to configure this setting when running celery through django?


Solution

  • Figured it out.

    In settings.py you need to set

    CELERY_TASK_SERIALIZER = "json"
    

    Docs are confusing, at least to me.