A Django app to register periodic Django Q tasks.
Project description
django-q-registry
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
-
Install the package from PyPI:
python -m pip install django-q-registry
-
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:
-
In a
tasks.pyfile in a Django app, using the@register_taskdecorator:# 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"], )
-
In a
tasks.pyfile in a Django app, using theregistry.registerfunction 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 * * * *", )
-
In a Django project's
settings.pyfile, using theQ_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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_q_registry-0.5.0.tar.gz.
File metadata
- Download URL: django_q_registry-0.5.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b07499087dceadd8ef66f102b8a9dbd4ba7be4aa7484a87ceda4f893e814da
|
|
| MD5 |
ed54d7edd97c67e3c0f3a91991bf4fc2
|
|
| BLAKE2b-256 |
16f460cd0727a4a6aea543e449fe4bf39ea4b0cb8feab6c28a38370fc37c8275
|
Provenance
The following attestation bundles were made for django_q_registry-0.5.0.tar.gz:
Publisher:
release.yml on westerveltco/django-q-registry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_q_registry-0.5.0.tar.gz -
Subject digest:
97b07499087dceadd8ef66f102b8a9dbd4ba7be4aa7484a87ceda4f893e814da - Sigstore transparency entry: 164195596
- Sigstore integration time:
-
Permalink:
westerveltco/django-q-registry@b490b2059805535ece09beeb4cc7ce90c84bf368 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/westerveltco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b490b2059805535ece09beeb4cc7ce90c84bf368 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_q_registry-0.5.0-py3-none-any.whl.
File metadata
- Download URL: django_q_registry-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a034db99abdc4d5d9ccb765a96b6e2e457ed2dc3626ee290ea8bc10e2ea823f
|
|
| MD5 |
3e5bcdbec703f62c80cb765e36eea426
|
|
| BLAKE2b-256 |
b74dcb290e86d2cf6675f13f403bb599b1dee93d7a5a9a8607f3b79473456a1e
|
Provenance
The following attestation bundles were made for django_q_registry-0.5.0-py3-none-any.whl:
Publisher:
release.yml on westerveltco/django-q-registry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_q_registry-0.5.0-py3-none-any.whl -
Subject digest:
6a034db99abdc4d5d9ccb765a96b6e2e457ed2dc3626ee290ea8bc10e2ea823f - Sigstore transparency entry: 164195608
- Sigstore integration time:
-
Permalink:
westerveltco/django-q-registry@b490b2059805535ece09beeb4cc7ce90c84bf368 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/westerveltco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b490b2059805535ece09beeb4cc7ce90c84bf368 -
Trigger Event:
release
-
Statement type: