Skip to main content

django-q-registry

PyPI PyPI - Python Version Django Version

A Django app to register periodic Django Q tasks.

Requirements

  • Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
  • Django 4.2, 5.0
  • Django Q2 1.4.3+
    • This package has only been tested with the Django ORM broker.

Installation

  1. Install the package from PyPI:

    python -m pip install django-q-registry
    
  2. Add the app to your Django project's INSTALLED_APPS:

    INSTALLED_APPS = [
        ...,
        "django_q_registry",
        ...,
    ]
    

Getting Started

Registering Periodic Tasks

There are three supported ways to register periodic tasks:

  1. In a tasks.py file in a Django app, using the @register_task decorator:

    # tasks.py
    from django.core.mail import send_mail
    from django_q.models import Schedule
    from django_q_registry import register_task
    
    
    @register_task(
        name="Send periodic test email",
        schedule_type=Schedule.CRON,
        # https://crontab.guru/#*/5_*_*_*_*
        cron="*/5 * * * *",
    )
    def send_test_email():
        send_mail(
            subject="Test email",
            message="This is a test email.",
            from_email="noreply@example.com",
            recipient_list=["johndoe@example.com"],
        )
    
  2. In a tasks.py file in a Django app, using the registry.register function directly:

    # tasks.py
    from django.core.mail import send_mail
    from django_q.models import Schedule
    from django_q_registry.registry import registry
    
    
    registry.register(
        send_mail,
        name="Send periodic test email",
        kwargs={
            "subject": "Test email",
            "message": "This is a test email.",
            "from_email": "noreply@example.com",
            "recipient_list": ["janedoe@example.com"],
        },
        schedule_type=Schedule.CRON,
        # https://crontab.guru/#*/5_*_*_*_*
        cron="*/5 * * * *",
    )
    
  3. In a Django project's settings.py file, using the Q_REGISTRY["TASKS"] setting:

    # settings.py
    from django_q.models import Schedule
    
    
    Q_REGISTRY = {
        "TASKS": [
            {
                "name": "Send periodic test email",
                "func": "django.core.mail.send_mail",
                "kwargs": {
                    "subject": "Test email",
                    "message": "This is a test email.",
                    "from_email": "noreply@example.com",
                    "recipient_list": ["janedoe@example.com"],
                },
                "schedule_type": Schedule.CRON,
                # https://crontab.guru/#*/5_*_*_*_*
                "cron": "*/5 * * * *",
            },
        ],
    }
    

Setting up Periodic Tasks in Production

At some point in your project's deployment process, run the setup_periodic_tasks management command:

python manage.py migrate
python manage.py setup_periodic_tasks

This command automatically registers periodic tasks from tasks.py files in Django apps, and from the Q_REGISTRY["TASKS"] setting. It also cleans up any periodic tasks that are no longer registered.

Documentation

Please refer to the documentation for more information.

License

django-q-registry is licensed under the MIT license. See the LICENSE file for more information.

Metadata

Release files for django-q-registry 0.5.0

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-q-registry 0.5.0
File Size Uploaded Provenance
django_q_registry-0.5.0.tar.gz 21.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-q-registry 0.5.0
File Interpreter ABI Platform
django_q_registry-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / django_q_registry-0.5.0.tar.gz

Download URL django_q_registry-0.5.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
97b07499087dceadd8ef66f102b8a9dbd4ba7be4aa7484a87ceda4f893e814da
BLAKE2b-256 checksum
How to use checksums
16f460cd0727a4a6aea543e449fe4bf39ea4b0cb8feab6c28a38370fc37c8275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 21, 2025.

Transparency log

Release files / django_q_registry-0.5.0-py3-none-any.whl

Download URL django_q_registry-0.5.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a034db99abdc4d5d9ccb765a96b6e2e457ed2dc3626ee290ea8bc10e2ea823f
BLAKE2b-256 checksum
How to use checksums
b74dcb290e86d2cf6675f13f403bb599b1dee93d7a5a9a8607f3b79473456a1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 21, 2025.

Transparency log

Security for django-q-registry 0.5.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_q_registry-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 21, 2025.

Transparency log

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