rsinger86/django-lifecycle

@hook does not work if model does not inherit from LifecycleModelMixin first

rabcau opened this issue · 1 comments

Hi there! I've just created a simple model:

class SomeModel(models.Model, LifecycleModelMixin):
    is_active = models.BooleanField(default=False)

    def __str__(self):
        return str(self.is_active)

    @hook(AFTER_UPDATE, when='is_active', was=True, is_now=False)
    def is_active_signal(self):
        print('works')

It didn't work until I inverted models.Model and LifecycleModelMixin. I don’t know if this is a bug or not, but if not, then it should be described in the documentation, I guess.

Best wishes.
Raman.

It is required.

In docs model's inherit from LifecycleModel

class LifecycleModel(LifecycleModelMixin, models.Model):
    class Meta:
        abstract = True

which is inheriting from LifecycleModelMixin