Django-fsm adds simple declarative state management for Django models. If you need parallel task execution, view, and background task code reuse over different flows - check my new project Django-view flow. Instead of adding a state field to a Django model and managing its values by hand, you use FSMField and mark model methods with the transition decorator. These methods could contain side effects of the state change. You may also take a look at the Django-fsm-admin project containing a mixin and template tags to integrate Django-fsm state transitions into the Django admin. FSM really helps to structure the code, especially when a new developer comes to the project. FSM is most effective when you use it for some sequential steps. Transition logging support could be achieved with help of django-fsm-log package.
Features
- The field parameter accepts both a string attribute name or an actual field instance
- Add FSMState field to your model
- Use the transition decorator to annotate model methods
- You can use * for source to allow switching to target from any state
- You can use + for source to allow switching to target from any state exluding target state
- target state parameter could point to a specific state or django_fsm.State implementation