Django FSM-2
Django FSM-2 adds simple, declarative state management to Django models.
Django FSM-2 is a maintained fork of django-fsm. It is a drop-in replacement with updated dependencies and ongoing maintenance.
Quick start
from django.db import models
from django_fsm import FSMField, FSMModelMixin, transition
class BlogPost(FSMModelMixin, models.Model):
state = FSMField(default='new')
@transition(field=state, source='new', target='published')
def publish(self, **kwargs):
pass
from django_fsm import can_proceed
post = BlogPost.objects.get(pk=1)
if can_proceed(post.publish):
post.publish()
post.save()
What next
- Start with the Installation guide.
- Read the Fields and Transitions docs for core concepts.
- When you are ready, check Admin Integration or Graphing.