Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viewflow/django-fsm
Django friendly finite state machine support
https://github.com/viewflow/django-fsm
django finite-state-machine fsm python state-machine state-machine-diagram
Last synced: 3 months ago
JSON representation
Django friendly finite state machine support
- Host: GitHub
- URL: https://github.com/viewflow/django-fsm
- Owner: viewflow
- License: mit
- Archived: true
- Created: 2010-05-31T14:03:48.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T12:13:04.000Z (8 months ago)
- Last Synced: 2024-05-23T08:31:47.003Z (7 months ago)
- Topics: django, finite-state-machine, fsm, python, state-machine, state-machine-diagram
- Language: Python
- Homepage:
- Size: 361 KB
- Stars: 2,317
- Watchers: 46
- Forks: 310
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-dj - django-fsm
- best-of-web-python - GitHub - 0% open · ⏱️ 16.04.2024): (Django Utilities)
README
Django friendly finite state machine support
============================================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
About
=====Finite state machine workflows is the declarative way to describe consecutive
operation through set of states and transitions between them.:mod:`viewflow.fsm` can help you manage rules and restrictions around moving
from one state to another. The package could be used to get low level
db-independent fsm implementation, or to wrap existing database model, and
implement simple persistent workflow process with quickly bootstrapped UI.Quick start
===========All things are buit around :class:`viewflow.fsm.State`. It is the special class
slot, that can take a value only from a specific `python enum`_ or `django
enumeration type`_ and that value can't be changed with simple assignement... code::
from enum import Enum
from 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 # True
flow.state = Stage.DONE # Raises AttributeErrorflow.complete()
flow.state == Stage.DONE # Trueflow.complete() # Now raises TransitionNotAllowed
Documentation
=============Full documentation available at https://docs.viewflow.io/fsm/index.html