我想使用某些功能作为计时任务
我的views.py:
class SomeHandler:
def __init__(self, user, instance):
self.user = user
self.instance = instance
@task(filter=task_method)
def send_some_msg(self, send_type):
XXXXXXXXXXXXXXX
我的admin.py:
def somefunction(self, obj):
user = self._user_filter(obj)
name = obj.id
task = "myapp.views.send_some_msg"
crontab_time = {
'month_of_year': obj.timing.month,
'day_of_month': obj.timing.day,
'hour': obj.timing.hour,
'minute': obj.timing.minute
}
crontab = celery_models.CrontabSchedule.objects.create(**crontab_time)
task = celery_models.PeriodicTask.objects.create(
name=name, task=task, kwargs=json.dumps({'send_type': True}), enabled=True, crontab=crontab, expires=obj.timing + timedelta(days=1)
)
但是我对芹菜工人犯了错误
TypeError: save_multiple_notification() missing 1 required positional argument: 'self'
我该如何使用该任务?我无法为“任务”字符串带来价值