Celery Progress (celery-progress) is a Python library that provides drop-in, configurable, dependency-free progress bars for Django/Celery applications. It enables real-time progress updates for long-running asynchronous tasks directly in the web UI. Currently at version 0.5, it is actively maintained and offers simple integration with Django's URL routing and Celery's task management, including support for group results.
pip install celery-progressVerified import paths — ran on the pinned version, not inferred.
To use `celery-progress`, first ensure Celery and Django are configured with a result backend (e.g., Redis). Add `celery_progress` to `INSTALLED_APPS` and include its URL patterns using `django.urls.path`. In your Celery task, import `ProgressRecorder`, instantiate it with `self` (from `bind=True`), and call `set_progress(current, total, description)` to update the state. In a Django view, call your task with `.delay()` to get the `task_id`, then pass this `task_id` to your template. In the frontend HTML, include the `celery_progress.js` static file and initialize `CeleryProgressBar` with the task status URL. The `onSuccess` callback can be used to handle task completion and display results.
Update your project's `urls.py` to use `path('celery-progress/', include('celery_progress.urls'))` or `re_path(r'^celery-progress/', include('celery_progress.urls'))` instead of `url()` for compatibility with Django 4+.Wrap the `celery_progress.views.get_progress` view in your own Django view with appropriate permission checks (e.g., `@login_required` or custom permissions) and route to your protected view instead of the default `celery_progress.urls`.
Ensure `CELERY_RESULT_BACKEND` is explicitly set in your Django settings. For example, `CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'` or `CELERY_RESULT_BACKEND = 'rpc://'` (with caution).
For applications with multiple concurrent tasks or needing persistent result storage, use a persistent result backend like Redis (`redis://`) or a database backend (`db+postgresql://`).