mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 01:28:13 +08:00
using PRE_SAVE instead of POST_SAVE signal for hook.
This commit is contained in:
+2
-3
@@ -2,7 +2,7 @@ import importlib
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import pre_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from picklefield import PickledObjectField
|
from picklefield import PickledObjectField
|
||||||
|
|
||||||
@@ -30,8 +30,7 @@ class Task(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'django_q'
|
app_label = 'django_q'
|
||||||
|
|
||||||
|
@receiver(pre_save, sender=Task)
|
||||||
@receiver(post_save, sender=Task)
|
|
||||||
def call_hook(sender, instance, **kwargs):
|
def call_hook(sender, instance, **kwargs):
|
||||||
if instance.hook:
|
if instance.hook:
|
||||||
module, func = instance.hook.rsplit('.', 1)
|
module, func = instance.hook.rsplit('.', 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user