Skip to main content

django-celery-model is an extension to Celery which adds support for tracking Celery tasks assigned to Django model instances.

Installation

Install the latest version from pypi.python.org:

pip install django-celery-model

Install the development version by cloning the source from github.com:

pip install git+https://github.com/mback2k/django-celery-model.git

Configuration

Add the package to your INSTALLED_APPS:

INSTALLED_APPS += (
    'djcelery_model',
)

Make sure that you are receiving Celery events via:

CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_SEND_SENT_EVENT = True
CELERY_SEND_EVENTS = True

Example

Add the TaskMixin to your Django model:

from django.db import models
from django.utils.translation import ugettext_lazy as _
from djcelery_model.models import TaskMixin

class MyModel(TaskMixin, models.Model):
    name = models.CharField(_('Name'), max_length=100)

Queue an asynchronous task from your Django model instance:

from .models import MyModel
from .tasks import mytask

mymodel = MyModel.objects.get(name='test instance')
mymodel.apply_async(mytask, ...)

Retrieve list of asynchronous tasks assigned to your Django model instance:

mymodel.tasks.all()
mymodel.tasks.pending()
mymodel.tasks.started()
mymodel.tasks.retrying()
mymodel.tasks.failed()
mymodel.tasks.successful()
mymodel.tasks.running()
mymodel.tasks.ready()

Check for a running or ready asynchronous task for your Django model instance:

mymodel.has_running_task
mymodel.has_ready_task

Handle asynchronous task results for your Django model instance:

mymodel.get_task_results()
mymodel.get_task_result(task_id)
mymodel.clear_task_results()
mymodel.clear_task_result(task_id)

Filter your Django model based upon asynchronous tasks:

MyModel.objects.with_tasks()
MyModel.objects.with_pending_tasks()
MyModel.objects.with_started_tasks()
MyModel.objects.with_retrying_tasks()
MyModel.objects.with_failed_tasks()
MyModel.objects.with_successful_tasks()
MyModel.objects.with_running_tasks()
MyModel.objects.with_ready_tasks()

MyModel.objects.without_tasks()
MyModel.objects.without_pending_tasks()
MyModel.objects.without_started_tasks()
MyModel.objects.without_retrying_tasks()
MyModel.objects.without_failed_tasks()
MyModel.objects.without_successful_tasks()
MyModel.objects.without_running_tasks()
MyModel.objects.without_ready_tasks()

License

Metadata

Release files for django-celery-model 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-celery-model 0.2.1
File Size Uploaded Provenance Actions
django-celery-model-0.2.1.tar.gz 6.4 kB Without provenance Details for django-celery-model-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-celery-model 0.2.1
File Interpreter ABI Platform Actions
django_celery_model-0.2.1-py3-none-any.whl Python 3 none any Details for django_celery_model-0.2.1-py3-none-any.whl

Total release size: 15.4 kB

Release files / django-celery-model-0.2.1.tar.gz

Download URL django-celery-model-0.2.1.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a77067244f215115b09a8718471df0d1c28069dc4093965e2b18b85297bf1f87
BLAKE2b-256 checksum
How to use checksums
836ee6029b5bfd7340503ecb5b95b4f2dcc4af56a1fbd1f127b45cfb4ca2c243
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / django_celery_model-0.2.1-py3-none-any.whl

Download URL django_celery_model-0.2.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
698c1c1ee42f33919a4be2fbc5ef7406e5008cc9803f07b7a7b07da473f9061d
BLAKE2b-256 checksum
How to use checksums
99c3e920bdfbbde2279be6919d2661efe8338387c5ce48fb4f12b050984b2a8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Security for django-celery-model 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page