From 5fe5b5fe371172d4ea005ea43fdc11e06b4d0f1a Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Mon, 29 Jun 2020 11:38:50 +0200 Subject: [PATCH] Adds cron kwarg --- django_q/tasks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django_q/tasks.py b/django_q/tasks.py index c27eb8b..27145f1 100644 --- a/django_q/tasks.py +++ b/django_q/tasks.py @@ -88,6 +88,7 @@ def schedule(func, *args, **kwargs): :param repeats: how many times to repeat. 0=never, -1=always. :param next_run: Next scheduled run. :type next_run: datetime.datetime + :param cron: optional cron expression :param kwargs: function keyword arguments. :return: the schedule object. :rtype: Schedule @@ -98,6 +99,7 @@ def schedule(func, *args, **kwargs): minutes = kwargs.pop("minutes", None) repeats = kwargs.pop("repeats", -1) next_run = kwargs.pop("next_run", timezone.now()) + cron = kwargs.pop("cron", None) # check for name duplicates instead of am unique constraint if name and Schedule.objects.filter(name=name).exists(): @@ -114,6 +116,7 @@ def schedule(func, *args, **kwargs): minutes=minutes, repeats=repeats, next_run=next_run, + cron=cron )