1👍
Could it be possible using a Mixin?
class YourMixin:
# if you want to trigger the task on save:
def save(self, *args, **kwargs):
ret = super().save(*args, **kwargs)
some_task.apply_async((
self.__class__.__name__,
self.pk,
))
return ret
@task()
def some_task(model_name, model_id):
my_model = apps.get_model('django_app_name.{}'.format(model_name))
obj = my_model.objects.get(pk=model_id)
Source:stackexchange.com