"Workflow Management Using Finite State Machine in Django"
summary
Shows how to instrument Django models with an actual finite state machine using django-fsm and its add-ons so transitions are methods not ad‑hoc field edits. Demonstrates FSMIntegerField choices, pre/post signals, concurrent locking requirements, a middleware pattern to inject the current user, and automatic audit entries with django-fsm-log. Covers admin integration with guarded buttons, the management command that emits graphviz diagrams, and practical tips like using the FSM admin commit flag to make state changes safe and auditable.
AI-written summary · about
chapters (26)
- 0:00Introduction
- 1:26What are workflows
- 3:11Simple workflow example
- 4:36Limitations of boolean fields
- 6:02Collaboration workflows
- 7:06Real-world workflow example
- 8:51Cancer research workflow
- 12:49Workflow in Django
- 15:17Introducing Django FSM
- 16:21Django FSM basics
- 18:04FSM field setup
- 20:11Defining workflow states
- 20:53Model transitions
- 23:48Handling errors in transitions
- 25:14Permissions in transitions
- 28:09Convenience methods
- 30:38FSM signals
- 31:40Post-transition actions
- 32:42Tracking user actions
- 34:11Concurrent locking
- 34:54Audit logging
- 35:59Going all-in with FSM
- 36:41Django admin integration
- 37:48Bonus: Graph transitions
- 39:33Visualizing workflows
- 39:54Q&A
