Getting Started

  1. Install and enable it

    pip install django-river
  2. 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()
  3. Create all your states on the admin page

  4. Create a workflow with your model ( MyModel - my_state_field ) information on the admin page

  5. Create your transition metadata within the workflow created earlier, source and destination states

  6. Create your transition approval metadata within the workflow created earlier and authorization rules along with their priority on the admin page

  7. Enjoy your django-river journey.

    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


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.