Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
/django-fsmPublic archive

Django friendly finite state machine support

License

NotificationsYou must be signed in to change notification settings

viewflow/django-fsm

Repository files navigation

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 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.

Quick start

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

Documentation

Full documentation available athttps://docs.viewflow.io/fsm/index.html


[8]ページ先頭

©2009-2025 Movatter.jp