Back to Skills

django-celery

Django + Celery async task patterns — configuration, task design, beat scheduling, retries, canvas workflows, monitoring, and testing. Use when adding background jobs, scheduled tasks, or async processing to a Django app.

230,578stars35,187forksUpdated 7/17/2026

Security Assessment

High Risk(40/100)

Detected risks:

Persistence([SKILL.md] crontab, [SKILL.md] Crontab)
Sensitive File Access([SKILL.md] .env)
Security Score40/100

About django-celery

django-celery provides production-grade patterns for background and asynchronous task processing in Django using Celery with Redis or RabbitMQ. It is meant for adding background jobs or async processing to a Django app, implementing periodic or scheduled tasks, offloading slow operations such as email, PDF generation, or API calls from the request cycle, setting up Celery Beat for cron-like scheduling, debugging task failures, retries, or queue backlogs, and writing tests for Celery tasks.

The skill covers project setup end to end: installing celery[redis], django-celery-results, and django-celery-beat; defining the Celery app in config/celery.py with config_from_object and autodiscover_tasks; and configuring Django settings including CELERY_BROKER_URL, CELERY_RESULT_BACKEND (django-db), JSON serialization, task behavior flags like CELERY_TASK_TIME_LIMIT, CELERY_TASK_SOFT_TIME_LIMIT, CELERY_WORKER_PREFETCH_MULTIPLIER, and CELERY_TASK_ACKS_LATE, and the DatabaseScheduler for Beat. It shows how to run workers and the beat scheduler and route queues with --concurrency and -Q. Task design patterns include basic shared_task definitions, retryable tasks using max_retries, autoretry_for, retry_backoff, retry_backoff_max, and retry_jitter, idempotent tasks that guard updates, and soft-time-limit handling via SoftTimeLimitExceeded. It demonstrates calling tasks with delay and apply_async (countdown, eta, queue routing), plus running synchronously with apply for tests. Beat scheduling is shown both code-defined via CELERY_BEAT_SCHEDULE with crontab, and database-defined through django_celery_beat models like PeriodicTask and CrontabSchedule. Canvas workflows cover chain, group, and chord for sequencing, parallelizing, and combining tasks with callbacks.

The skill is aimed at Django developers building reliable background processing, emphasizing production-safe defaults such as prefetch multiplier of 1 to prevent worker hoarding, acks-late to re-queue on crashes, and idempotent task design so tasks can safely run multiple times. It notes practical guidance like never combining worker and beat in production, and using synchronous execution only in tests or debugging. It is documented in a single SKILL.md with extensive code examples and originates from the ECC collection.

FAQ

What packages and brokers does it use?

It installs celery[redis], django-celery-results, and django-celery-beat, and supports Redis or RabbitMQ as the broker, with Redis recommended for production. Results can be stored via the django-db result backend.

How does it handle task retries?

Through retryable tasks configured with options like max_retries, default_retry_delay, autoretry_for for specific exceptions (e.g. ConnectionError, TimeoutError), retry_backoff for exponential backoff, retry_backoff_max to cap delay, and retry_jitter to avoid thundering herd. Tasks can also call self.retry with a specific countdown.

How can I schedule periodic tasks?

Two ways: code-defined schedules via CELERY_BEAT_SCHEDULE using crontab or numeric intervals, or database-defined schedules using django_celery_beat models like PeriodicTask and CrontabSchedule managed from the Django admin or code. Beat runs with the DatabaseScheduler.

What are the canvas workflow primitives it covers?

chain to run tasks sequentially passing results, group to run tasks in parallel, and chord to run parallel tasks with a callback that fires when all complete.

What production practices does it emphasize?

Setting CELERY_WORKER_PREFETCH_MULTIPLIER to 1 to prevent worker hoarding of long tasks, CELERY_TASK_ACKS_LATE to re-queue on worker crash, designing idempotent tasks that guard their updates, never combining worker and beat in production, and using synchronous apply execution only for tests or debugging.

Install django-celery

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill