Integrations Overview
Django-CFG provides seamless integrations with essential third-party services and tools, making it easy to add powerful features to your Django application with minimal configuration.
Available Integrations
🔄 Background Tasks
Django-RQ Integration
Production-ready Redis-based task queue with built-in monitoring:
Core Features:
- ✅ High performance - 10,000+ jobs/second with low memory usage
- ✅ Redis-backed queue with automatic job persistence
- ✅ Type-safe configuration with Pydantic validation
- ✅ Worker management via CLI commands (rqworker, rqscheduler)
- ✅ Cron scheduling with RQ Scheduler for periodic tasks
- ✅ Built-in monitoring - Django Admin, REST API, Prometheus metrics
- ✅ Job dependencies and retry logic with exponential backoff
Use Cases:
- Email sending and notifications (Email Module)
- Payment processing (Payment System)
- Document processing (AI Knowledge Base)
- Bulk operations (Newsletter campaigns, data imports)
- Scheduled tasks (cleanup jobs, report generation)
🔧 Development Tools
Ngrok Integration
Secure tunnels for webhook testing in development:
Core Features:
- ✅ Automatic tunnel creation with custom subdomains
- ✅ HTTPS support for secure webhook delivery
- ✅ Custom domains with ngrok auth token
- ✅ Auto-configuration of ALLOWED_HOSTS and CSRF settings
- ✅ CLI integration with
runserver_ngrokcommand
Use Cases:
- Testing payment webhooks locally (Payment System)
- OAuth callback testing (Authentication)
- Third-party API webhooks
- Mobile app development
🔐 Authentication
Authentication Patterns
Enterprise authentication integration:
Core Features:
- ✅ JWT authentication with djangorestframework-simplejwt
- ✅ OAuth2/OIDC integration patterns
- ✅ Multi-factor authentication with OTP (User Management)
- ✅ Social auth with django-allauth patterns
- ✅ API key authentication for machine-to-machine
Use Cases:
- REST API authentication
- SSO with OAuth2/OIDC providers
- Multi-factor authentication
- API key management
📱 Communication
Twilio Integration
SMS and voice communication integration:
Core Features:
- ✅ SMS messaging with Twilio API
- ✅ Voice calls and IVR integration
- ✅ Number verification via SMS
- ✅ Webhook handling for delivery status
- ✅ Type-safe configuration with Pydantic
Alternatives:
- Telegram Integration - Bot-based notifications
Use Cases:
- SMS notifications and alerts
- Two-factor authentication
- Voice calls and IVR systems
- Phone number verification
📐 Best Practices
Integration Patterns
Common patterns and best practices:
Core Patterns:
- ✅ Webhook handling patterns and security
- ✅ API client configuration and error handling
- ✅ Rate limiting and retry strategies
- ✅ Secret management with environment variables
- ✅ Testing strategies for third-party integrations
Use Cases:
- Building robust webhook handlers
- Implementing API rate limiting
- Managing third-party secrets
- Testing external integrations
Quick Start
Enable Django-RQ for Background Tasks
# api/config.py
from django_cfg import DjangoConfig
from django_cfg.models import DjangoRQConfig, RQQueueConfig
class MyConfig(DjangoConfig):
redis_url: str = "redis://localhost:6379/0"
django_rq: DjangoRQConfig = DjangoRQConfig(
enabled=True,
queues=[
RQQueueConfig(queue="default"),
],
)# apps/myapp/tasks.py
def send_welcome_email(user_id: int):
"""Task runs in background worker."""
# Task code here
pass
# Enqueue from anywhere
import django_rq
queue = django_rq.get_queue('default')
queue.enqueue('apps.myapp.tasks.send_welcome_email', user_id=123)Enable Ngrok for Webhook Testing
# config.dev.yaml
ngrok:
enabled: true
subdomain: "myapp" # myapp.ngrok.io
auth_token: "${NGROK_AUTH_TOKEN}"# Start server with ngrok tunnel
python manage.py runserver_ngrokIntegration Architecture
Type-Safe Configuration
All integrations use Pydantic v2 for validation:
from django_cfg import DjangoConfig
from django_cfg.models import DjangoRQConfig, RQQueueConfig, NgrokConfig
class MyConfig(DjangoConfig):
redis_url: str = "redis://localhost:6379/0"
# Django-RQ configuration
django_rq: DjangoRQConfig = DjangoRQConfig(
enabled=True,
queues=[
RQQueueConfig(queue="default"),
RQQueueConfig(queue="high"),
],
)
# Ngrok configuration
ngrok: NgrokConfig | None = NgrokConfig(
enabled=True,
subdomain="myapp"
)Environment-Based Enablement
Enable integrations per environment using environment detection:
class MyConfig(DjangoConfig):
@property
def ngrok(self) -> NgrokConfig | None:
# Only enable ngrok in development
if self.is_development:
return NgrokConfig(enabled=True)
return NoneAutomatic Django Integration
Integrations automatically configure Django settings:
- Django-RQ: Configures RQ_QUEUES, Redis connections, worker management
- Ngrok: Updates ALLOWED_HOSTS, CSRF_TRUSTED_ORIGINS, generates public URL
- Auth: Configures authentication backends, middleware, JWT settings
Integration Comparison
| Integration | Type | Production Ready | Auto-Config | CLI Tools |
|---|---|---|---|---|
| Django-RQ | Task Queue | ✅ Yes | ✅ Yes | ✅ rqworker, rqscheduler, rqstats |
| Ngrok | Development Tool | ⚠️ Dev Only | ✅ Yes | ✅ runserver_ngrok |
| Auth | Security | ✅ Yes | ✅ Yes | ✅ test_auth |
| Twilio | Communication | ✅ Yes | ✅ Yes | ✅ test_sms |
Configuration Best Practices
1. Use Environment Variables for Secrets
# config.prod.yaml
ngrok:
auth_token: "${NGROK_AUTH_TOKEN}" # From environment
twilio:
account_sid: "${TWILIO_ACCOUNT_SID}"
auth_token: "${TWILIO_AUTH_TOKEN}"2. Disable in Production When Not Needed
class ProductionConfig(DjangoConfig):
# Ngrok only for development
ngrok: None = None
# Django-RQ for production background tasks
django_rq: DjangoRQConfig = DjangoRQConfig(
enabled=True,
queues=[
RQQueueConfig(queue="high"),
RQQueueConfig(queue="default"),
RQQueueConfig(queue="low"),
],
)3. Test Integrations Before Production
# Test Django-RQ workers
python manage.py rqworker default
# Check queue stats
python manage.py rqstats
# Test Twilio SMS
python manage.py test_sms +1234567890
# Test ngrok tunnel (dev only)
python manage.py runserver_ngrok --testSee Also
Core Integrations
Background Processing:
- Django-RQ Overview - Complete task queue guide
- Django-RQ Architecture - System design and components
- Django-RQ Configuration - Setup and configuration
- Django-RQ Examples - Real-world task patterns
- Django-RQ Monitoring - Task monitoring and observability
Development Tools:
- Ngrok Overview - Webhook testing guide
- Ngrok Configuration - Tunnel configuration
Authentication:
- Auth Patterns - Enterprise authentication
- User Management - Built-in user system
Communication:
- Twilio Integration - SMS and voice
- Telegram Module - Bot notifications
- Email Module - Email sending
Configuration & Setup
Getting Started:
- Configuration Guide - Enable integrations
- Configuration Models - Integration config API
- Environment Detection - Environment-specific integrations
Infrastructure:
- Redis Configuration - Redis setup for Django-RQ
- Security Settings - Webhook signature verification
- Environment Variables - Manage API keys securely
Related Features
Apps Using Integrations:
- Payment System - Uses Django-RQ for async processing
- AI Knowledge Base - Uses Django-RQ for document processing
- Newsletter - Uses Django-RQ for bulk emails
Other Modules:
- Modules Overview - All available modules
- LLM Module - AI model integration
Tools & Guides
CLI Commands:
- CLI Introduction - All CLI tools
Guides:
- Integration Patterns - Best practices
- Production Config - Production integration setup
- Troubleshooting - Common integration issues
Next Steps
New to Integrations?
- Start with Django-RQ Overview for background tasks
- Try Ngrok Overview for webhook testing
- Review Integration Patterns for best practices
Ready for Production?
- Review Production Config
- Set up Redis for Django-RQ
- Configure environment variables for secrets
- Deploy workers using Django-RQ Monitoring guide
Need Help?
Django-CFG integrations: Production-ready, type-safe, zero-config. 🚀