skillfed

django-fsm

Django friendly finite state machine support.

django-fsm v3.0.1 609.1K downloads/30d#5,776 on PyPI2,349
Permissive license MIT License AGING released

What it is and what it does

django-fsm is a finite state machine library for Django that lets you declare states and transitions declaratively using Python enums and decorators. Instead of allowing arbitrary state changes, it enforces a controlled workflow where transitions between states are explicitly defined and validated. You define a State field with an enum, then attach transition methods decorated with source and target states; calling a transition method moves the state forward only if the transition is allowed, otherwise it raises an exception.

The package is designed for low-level, database-independent FSM logic or as a wrapper around existing Django models to implement persistent workflow processes. It has been in development since 2010, with a major API redesign in version 3.0 that is incompatible with earlier versions. The library provides a simple way to enforce business rules around state changes without building custom validation logic.

Use it for:

  • Define multi-step approval workflows (e.g., draft → review → approved → published) with controlled transitions.
  • Implement order or payment state machines with validation rules and restricted state changes.
  • Build task or ticket lifecycle management where state changes are restricted by business logic.
  • Create document workflows with states like new, in-review, rejected, and finalized.
  • Enforce state-based permissions so only certain transitions are allowed from each state.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides finite state machine support for Django models, allowing you to define states and controlled transitions between them using decorators and enums.

Yes, with conditions. The package is stable and permissively licensed, with no known vulnerabilities and low install friction. However, the aging maintenance status (311 days since last release, marked inactive) and the breaking API change in version 3.0 mean you should verify that the current version meets your Django and Python requirements and that you're comfortable with limited active development.

Install

django-fsm on PyPI

pip

pip install django-fsm

uv

uv add django-fsm

poetry

poetry add django-fsm

Installing django-fsm

Before you install

Low install friction with no runtime dependencies. Maintenance status is aging—last release was 311 days ago and the package is marked as inactive in development status, though the repository remains active with 2349 stars.

License in practice

Licensed under MIT (permissive), so you can use, modify, and distribute the package freely with minimal restrictions.

Quickstart

from enum import Enum
from django_fsm import State

class Stage(Enum):
    NEW = 1
    DONE = 2

class MyFlow(object):
    state = State(Stage, default=Stage.NEW)
    
    @state.transition(source=Stage.NEW, target=Stage.DONE)
    def complete(self):
        pass

flow = MyFlow()
flow.complete()  # Transition to DONE

Verify before relying

  • Whether version 3.0.1 is a breaking change from 2.x and what migration effort is required.
  • Current maintenance timeline and whether aging status signals end-of-life or stable maintenance.
  • Minimum Python and Django version requirements not explicitly stated in metadata.

Package facts

License MIT License (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 311 days since the last release
Last repo commit
First released
Downloads 609,134/month — #5,776 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_fsm-3.0.1-py2.py3-none-any.whl

Keywords: django

Development Status :: 7 - InactiveEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 1.10Framework :: Django :: 1.11Framework :: Django :: 1.6Framework :: Django :: 1.8Framework :: Django :: 1.9Framework :: Django :: 2.0Framework :: Django :: 2.1Framework :: Django :: 2.2Framework :: Django :: 3.0Framework :: Django :: 3.1Framework :: Django :: 3.2Framework :: Django :: 4.0Framework :: Django :: 4.1Framework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

django state machinefinite state machine djangoworkflow state transitionsdjango fsmstate management djangodeclarative workflowstate transition rules
state-machineworkflowdjango-extension

More Python Modules packages