- Notifications
You must be signed in to change notification settings - Fork311
Django friendly finite state machine support
License
viewflow/django-fsm
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Django-fsm first came out in 2010 and had a big update in 2.0 release at 2014, making it incompatible with earlier versions. Now, ten years later at 2024, it's been updated to version 3.0 and renamed viewflow.fsm.
This new version has a different API that doesn't work with the old one but is better suited for today's needs.
Migration guide:
https://github.com/viewflow/viewflow/wiki/django%E2%80%90fsm-to-viewflow.fsm-Migration-Guide
Finite state machine workflows is the declarative way to describe consecutiveoperation through set of states and transitions between them.
:mod:`viewflow.fsm` can help you manage rules and restrictions around movingfrom one state to another. The package could be used to get low leveldb-independent fsm implementation, or to wrap existing database model, andimplement simple persistent workflow process with quickly bootstrapped UI.
All things are buit around:class:`viewflow.fsm.State`. It is the special classslot, that can take a value only from a specific`python enum`_ or`djangoenumeration type`_ and that value can't be changed with simple assignement.
from enum import Enumfrom viewflow.fsm import Stateclass Stage(Enum): NEW = 1 DONE = 2 HIDDEN = 3class MyFlow(object): state = State(Stage, default=Stage.NEW) @state.transition(source=Stage.NEW, target=Stage.DONE) def complete(): pass @state.transition(source=State.ANY, target=Stage.HIDDEN) def hide(): passflow = MyFlow()flow.state == Stage.NEW # Trueflow.state = Stage.DONE # Raises AttributeErrorflow.complete()flow.state == Stage.DONE # Trueflow.complete() # Now raises TransitionNotAllowed
Full documentation available athttps://docs.viewflow.io/fsm/index.html
About
Django friendly finite state machine support
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.