Getting Started¶
Install and enable it
pip install django-river
INSTALLED_APPS=[ ... river ... ]
Create your first state machine in your model and migrate your db
from django.db import models from river.models.fields.state import StateField class MyModel(models.Model): my_state_field = StateField()
Create all your
stateson the admin pageCreate a
workflowwith your model (MyModel-my_state_field) information on the admin pageCreate your
transition metadatawithin the workflow created earlier, source and destination statesCreate your
transition approval metadatawithin the workflow created earlier and authorization rules along with their priority on the admin pageEnjoy your
django-riverjourney.my_model=MyModel.objects.get(....) my_model.river.my_state_field.approve(as_user=transactioner_user) my_model.river.my_state_field.approve(as_user=transactioner_user, next_state=State.objects.get(label='re-opened')) # and much more. Check the documentation
Note
Whenever a model object is saved, it’s state field will be initialized with the
state is given at step-4 above by django-river.