Inherit from a State flow class to add or override transitions. Use
State.super() when the child should keep the parent’s transition rules
and add its own method behavior:
from django_fsm import State
class Review:
state = State(None, default='new')
@state.transition(source='new', target='hidden')
def hide(self):
return 'hidden by parent'
class GuestReview(Review):
@Review.state.super()
def hide(self):
result = super().hide.original()
return result + ' with guest handling'
review = GuestReview()
assert review.hide() == 'hidden by parent with guest handling'
assert review.state == 'hidden'
.original() invokes the parent method body without starting another
transition. The outer transition still checks its source and conditions,
applies its target, and restores state if the method raises.
Model fields support inherited transition methods and decorators that name a
field with field='status'. See Django Model State Fields for model-backed states.