`when_any` runs hook once per field changed
Maushundb opened this issue · 1 comments
Maushundb commented
Seems like when multiple tracked fields in when_any
change, the hook is fired that many times, rather than once as one would expect. #8 seems to address this but isn't merged.
class MyModel(LifecycleModelMixin, BaseModel):
...
@hook(AFTER_UPDATE, when_any=['foo', 'bar'], has_changed=True)
def run_hook(self):
print("hey")
model = MyModel()
model.foo = 1
model.bar = 2
model.save()
# prints "hey" twice
This does not appear to be the behavior when when_any
is omitted.
rsinger86 commented
Ah, nice catch.