This document provides an introduction to the django-celery-results project, a Django application that enables storing Celery task and group results using the Django ORM or cache framework. It serves as a foundation for understanding the purpose, architecture, and key components of the system before diving into more specific documentation.
Django-celery-results allows you to store and retrieve Celery task and group results using Django's Object-Relational Mapping (ORM) system or Django's cache framework. The primary goals of this extension are to:
For detailed installation instructions, please see Installation and Configuration. For specific usage examples, refer to Usage.
Sources: README.rst15-21 docs/includes/introduction.txt10-14
Django-Celery-Results System Architecture
Django-celery-results consists of several interconnected components:
Models: Define the structure for storing task and group results
TaskResult
: Stores information about individual tasksGroupResult
: Stores information about task groupsChordCounter
: Used for chord synchronizationBackends: Provide storage mechanisms for Celery results
DatabaseBackend
: Stores results in the database using Django ORMCacheBackend
: Stores results in Django's cache frameworkManagers: Handle database operations for models
TaskResultManager
: Manages operations on TaskResultGroupResultManager
: Manages operations on GroupResultAdmin: Provide Django admin interface for result management
TaskResultAdmin
: Admin interface for TaskResult modelGroupResultAdmin
: Admin interface for GroupResult modelViews: Provide API endpoints for accessing result data
Sources: README.rst16-21 docs/includes/introduction.txt12-14
Task Result Storage and Retrieval Flow
The diagram above illustrates the typical flow of data through the system:
Sources: README.rst16-21 docs/includes/introduction.txt10-14
Model Relationships
Django-celery-results defines three primary models:
TaskResult: Stores individual task results with the following key fields:
task_id
: Unique identifier for the task (primary key)status
: Current status of the task (e.g., SUCCESS, FAILURE)result
: The actual result of the taskdate_created
: When the task record was createddate_started
: When the task started execution (if tracking is enabled)date_done
: When the task was completedtraceback
: Error traceback (if the task failed)task_name
: Name of the task functionworker
: Name of the worker that executed the tasktask_args
: Arguments passed to the task (if extended result storage is enabled)task_kwargs
: Keyword arguments passed to the task (if extended result storage is enabled)periodic_task_name
: Name of the periodic task (if applicable)content_type
: Content type of the result (e.g., application/json)content_encoding
: Encoding of the result (e.g., utf-8)meta
: Additional metadata about the taskGroupResult: Stores information about task groups:
group_id
: Unique identifier for the group (primary key)result
: The combined results of the tasks in the groupdate_created
: When the group record was createddate_done
: When the group completedcontent_type
: Content type of the resultcontent_encoding
: Encoding of the resultChordCounter: Used for chord synchronization:
group_id
: Identifier for the group (chord header, primary key)sub_tasks
: Tasks that are part of the chord headercount
: Number of uncompleted tasksSources: README.rst18-21 docs/includes/introduction.txt12-14
Result Backend Configuration
Django-celery-results provides two types of result backends:
The primary backend that stores task and group results in the database using Django ORM. This provides persistent storage that survives application restarts and allows for complex queries.
Configuration:
Additional configuration options:
An alternative backend that stores results in Django's cache framework. This is typically faster but less permanent than the database backend.
Configuration:
Sources: README.rst16-21
Version information is stored as:
And parsed into a structured format:
Key features include:
Sources: django_celery_results/__init__.py12-31 .bumpversion.cfg1-8
Django-celery-results allows you to:
The extension also supports:
For Celery chords (a group of tasks followed by a callback):
Sources: README.rst16-20 docs/includes/introduction.txt10-14 Changelog13-23
Integration Architecture
Django-celery-results integrates with:
Django:
INSTALLED_APPS
in Django settings:
python manage.py migrate django_celery_results
Celery:
Sources: README.rst15-102 docs/includes/introduction.txt10-17
Django-celery-results provides a robust solution for storing and retrieving Celery task and group results using Django's familiar ORM interface. It offers both database and cache storage options, supports advanced Celery features like chords, and integrates seamlessly with Django's admin interface. This makes it an excellent choice for Django applications that need persistent and queryable storage for their Celery task results.
For more detailed information about specific components, please refer to the other pages in this documentation.
Sources: README.rst15-20 docs/includes/introduction.txt10-17 Changelog9-23
Auto-refresh not enabled yet
Try DeepWiki on your private codebase with Devin