
Django Celery
Add production-grade Celery workers, Beat schedules, retries, and tests to a Django app so slow work leaves the request path.
Overview
Django Celery is an agent skill most often used in Build (also Ship perf, Operate iterate) that teaches Django + Celery configuration, task design, Beat scheduling, retries, and testing.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill django-celeryWhat is this skill?
- Celery app entrypoint with autodiscover_tasks across INSTALLED_APPS
- Redis or RabbitMQ broker settings with django-celery-results and django-celery-beat
- Task design: retries, canvas workflows, and beat scheduling patterns
- Monitoring and queue backlog debugging guidance
- Testing strategies for bound tasks and periodic jobs
Adoption & trust: 1.1k installs on skills.sh; 210k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Django views time out because email, reports, and third-party calls run synchronously and you lack a reliable worker and schedule setup.
Who is it for?
Solo builders on Django SaaS or APIs who need dependable background jobs and periodic tasks without reinventing Celery boilerplate.
Skip if: Non-Django stacks, serverless-only architectures with no long-running workers, or trivial CRUD apps with no async workload.
When should I use this skill?
Adding background jobs, scheduled tasks, or async processing to a Django app; debugging Celery failures, retries, or queue backlogs; writing tests for tasks.
What do I get? / Deliverables
You configure a Celery app with broker, results, beat, and testable tasks so slow work runs in workers with retries and observable queues.
- config/celery.py and wired config/__init__.py celery_app export
- CELERY-namespaced Django settings and per-app tasks.py patterns
- Beat schedule definitions and test examples for tasks
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Background task wiring is core backend Build work when the product needs async email, exports, or webhooks. Backend subphase is the canonical shelf for Celery app setup, tasks.py patterns, and broker configuration inside Django.
Where it fits
Offload signup emails and PDF invoices from views into Celery tasks with autodiscovered tasks.py modules.
Move heavy API aggregation off the request cycle so p95 latency drops before launch traffic.
Diagnose stuck Beat schedules and retry policies when production queue depth spikes.
How it compares
Use instead of rolling custom thread pools in views when you want standard Celery queues, Beat, and Django integration patterns.
Common Questions / FAQ
Who is django-celery for?
Indie Django developers shipping SaaS or APIs who need Celery workers, scheduled jobs, and operational patterns agents can implement consistently.
When should I use django-celery?
During Build backend when adding async jobs; during Ship perf when offloading request hot paths; during Operate iterate when debugging task failures or queue backlogs.
Is django-celery safe to install?
It is documentation and code patterns only—review the Security Audits panel on this page and follow your own secret handling for broker URLs and Django settings.
SKILL.md
READMESKILL.md - Django Celery
# Django + Celery Async Task Patterns Production-grade patterns for background task processing in Django using Celery with Redis or RabbitMQ. ## When to Activate - Adding background jobs or async processing to a Django app - Implementing periodic/scheduled tasks - Offloading slow operations (email, PDF generation, API calls) from request cycle - Setting up Celery Beat for cron-like scheduling - Debugging task failures, retries, or queue backlogs - Writing tests for Celery tasks ## Project Setup ### Installation ```bash pip install celery[redis] django-celery-results django-celery-beat ``` ### `celery.py` — App Entrypoint ```python # config/celery.py import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.development') app = Celery('myproject') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() # Discovers tasks.py in each INSTALLED_APP @app.task(bind=True, ignore_result=True) def debug_task(self): print(f'Request: {self.request!r}') ``` ```python # config/__init__.py from .celery import app as celery_app __all__ = ('celery_app',) ``` ### Django Settings ```python # config/settings/base.py # Broker (Redis recommended for production) CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='redis://localhost:6379/0') CELERY_RESULT_BACKEND = env('CELERY_RESULT_BACKEND', default='django-db') # Serialization CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' # Task behavior CELERY_TASK_TRACK_STARTED = True CELERY_TASK_TIME_LIMIT = 30 * 60 # Hard limit: 30 min CELERY_TASK_SOFT_TIME_LIMIT = 25 * 60 # Soft limit: sends SoftTimeLimitExceeded CELERY_WORKER_PREFETCH_MULTIPLIER = 1 # Prevent worker hoarding long tasks CELERY_TASK_ACKS_LATE = True # Re-queue on worker crash # Result persistence CELERY_RESULT_EXPIRES = 60 * 60 * 24 # Keep results 24 hours # Beat scheduler (for periodic tasks) CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler' # Installed apps INSTALLED_APPS += [ 'django_celery_results', 'django_celery_beat', ] ``` ### Running Workers ```bash # Start worker (development) celery -A config worker --loglevel=info # Start beat scheduler (periodic tasks) celery -A config beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler # Combined worker + beat (dev only, never production) celery -A config worker --beat --loglevel=info # Production: multiple workers with concurrency celery -A config worker --loglevel=warning --concurrency=4 -Q default,high_priority ``` ## Task Design Patterns ### Basic Task ```python # apps/notifications/tasks.py from celery import shared_task import logging logger = logging.getLogger(__name__) @shared_task(name='notifications.send_welcome_email') def send_welcome_email(user_id: int) -> None: """Send welcome email to newly registered user.""" from apps.users.models import User from apps.notifications.services import EmailService try: user = User.objects.get(pk=user_id) except User.DoesNotExist: logger.warning('send_welcome_email: user %s not found', user_id) return # Idempotent — do not raise, task already impossible to complete EmailService.send_welcome(user) logger.info('Welcome email sent to user %s', user_id) ``` ### Retryable Task ```python @shared_task( bind=True, name='integrations.sync_to_crm', max_retries=5, default_retry_delay=60, # seconds before first retry autoretry_for=(ConnectionError, TimeoutError), retry_backoff=True, # exponential backoff retry_backoff_max=600, # cap at 1