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 )