Reputation: 523
I am using Django-q to schedule a task at a specified date in an object (lets call this bell). I am successfully able to do so using
schedule_obj = schedule(func_name, arg1, arg2, arg3,
schedule_type=Schedule.ONCE,
next_run=bell.date)
when there is an update to the obj bell that holds the date, I want to modify this schedule obj with the updated date (bell.date). Is there a way to check if there is a schedule pending for this specific func_name with the args and then access it to modify it?
Upvotes: 3
Views: 1217
Reputation: 4279
Leaving this here since I couldn't find it in the docs but you can access and modify a created django-q Schedule just like any other Django model.
As long as you update the next_run
and the schedule parameters for the type of schedule you're using, the cluster workers will use the updated info to run:
from django_q.models import Schedule
existing_schedules = Schedule.objects.filter(func=func_name, args=args)
for schedule in existing_schedules:
schedule.next_run = bell.date
schedule.save()
Upvotes: 2