Django, Flask, FastAPI integration patterns for Celery. Use when integrating Celery with Django, Flask, or FastAPI, setting up framework-specific configurations, handling application contexts, managing database transactions with tasks, configuring async workers, or when user mentions Django Celery, Flask Celery, FastAPI background tasks, framework integration, or web framework task queues.
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/celery/skills/framework-integrations/SKILL.md -a claude-code --skill framework-integrationsInstallation paths:
.claude/skills/framework-integrations/# Framework Integrations **Purpose:** Integrate Celery with Django, Flask, and FastAPI using framework-specific patterns and best practices. **Activation Triggers:** - Setting up Celery with Django/Flask/FastAPI - Application context issues in tasks - Database transaction handling - Framework-specific configuration - Async worker setup - Request context in background tasks **Key Resources:** - `templates/django-integration/` - Django app structure with Celery - `templates/flask-integration/` - Flask factory pattern with Celery - `templates/fastapi-integration/` - FastAPI async integration - `templates/transaction-safe-django.py` - Django transaction handling - `templates/fastapi-background.py` - FastAPI BackgroundTasks vs Celery - `templates/flask-context.py` - Flask app context in tasks - `scripts/test-integration.sh` - Test framework integration - `scripts/validate-framework.sh` - Validate framework setup - `examples/` - Complete integration examples ## Integration Patterns ### Django + Celery **Core Setup:** 1. **Install packages:** ```bash pip install celery django-celery-beat django-celery-results ``` 2. **Project structure:** ``` myproject/ ├── myproject/ │ ├── __init__.py │ ├── celery.py # Celery app configuration │ ├── settings.py # Django settings with Celery config │ └── urls.py ├── myapp/ │ ├── tasks.py # Task definitions │ └── views.py # Views that call tasks └── manage.py ``` 3. **Use template:** ```bash # Copy Django integration template cp -r templates/django-integration/* /path/to/project/ ``` **Key Patterns:** **Transaction-Safe Tasks:** - Template: `templates/transaction-safe-django.py` - Use `transaction.on_commit()` to delay task execution - Prevents tasks from running before database commits - Essential for tasks that depend on database state **Django ORM in Tasks:** - Always use ORM (don't pass model instances) - Pass primary keys, reload in task - Close connections explicitly if needed - Use `CELERY_