diff --git a/backend/apps/lunarlink/utils/task.py b/backend/apps/lunarlink/utils/task.py index 7d7417c..2186bed 100644 --- a/backend/apps/lunarlink/utils/task.py +++ b/backend/apps/lunarlink/utils/task.py @@ -98,8 +98,9 @@ def update_task(self, task_id): :return: """ self.format_crontab() - task_obj = celery_models.PeriodicTask.objects.filter(id=task_id) - if not task_obj: + try: + task_obj = celery_models.PeriodicTask.objects.get(id=task_id) + except celery_models.PeriodicTask.DoesNotExist: raise TaskNotFound crontab = celery_models.CrontabSchedule.objects.filter(