celery 周期任务的扩展保存方法

问题描述

我想对 celery 的 PeriodicTask 进行一些自定义验证。我已覆盖 save 方法并尝试在管理面板中保存该对象。但是,它不会调用我的重写方法。我应该在某处注册我的模型吗?

models.py 在我的应用中

from django.db import models
from django_celery_beat.models import PeriodicTask
from django.core.exceptions import ValidationError

# Create your models here.

class MyPeriodicTask(PeriodicTask):
    def save(self,*args,**kwargs):
        raise ValidationError('can not save') # only to check if this is called

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)