Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (32 sloc) 1.57 KB

Getting Started

  1. Install and enable it

    pip install django-river
    INSTALLED_APPS=[
    ...
    river
    ...
    ]
  1. Create your first state machine in your model

    from django.db import models
    from river.models.fields.state import StateField
    
    class MyModel(models.Model):
        my_state_field = StateField()
  1. Create your states as one of them will be your initial state on the admin page (Look at :ref:`state-administration`.)

  2. Create your transition approval metadata with your model (MyModel - my_state_field) information and authorization rules along with their priority on the admin page (Look at :ref:`transition-approval-meta-administration`.)

  3. Enjoy your django-river journey.

    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-3 above by django-river.

Note

Make sure that there is only one initial state defined in your workflow, so that django-river can pick that one automatically when a model object is created. All other workflow items will be managed by django-river after object creations.