Open
Description
I'm trying to migrate an internal application to use django-q-registry
. I have this task that needs to run periodically:
from __future__ import annotations
from django_q.models import Schedule
from django_q_registry import register_task
from assets.employees.models import Supervisor
@register_task(
name="Send quarterly Asset Reports to all Supervisors",
schedule_type=Schedule.QUARTERLY,
)
def send_asset_reports():
for supervisor in Supervisor.objects.all():
supervisor.send_assets_report()
It exists in the database as an unmanaged Schedule
, with the next run date a couple months in the future. I don't want to pass next_run
to the register_task
decorator because when I remove it the internals of this library would consider it a 'new' task and remove it and recreate it with the next run time being right now.
I don't want it to run right now, I'd like to temporarily pass in the initial time to run, then have setup_periodic_tasks
run to create it with this initial time set as the next run time, and then finally remove the initial time without the library thinking it's a completely new Task.