Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Django 5 Advanced Architecture & Celery 22 mins read Free Lesson

Asynchronous Background Tasks in Django with Celery & Redis

Offload slow email notifications and PDF generation to background Celery workers.

Celery Task Definition

# tasks.py
from celery import shared_task
from django.core.mail import send_mail

@shared_task
def send_welcome_email_task(user_email: str, user_name: str):
    send_mail(
        'Welcome to E-Tutorial!',
        f'Hello {user_name}, your free account is ready.',
        'no-reply@etutorial.com',
        [user_email]
    )