Mixins and Base Classes

Transition Base Classes

Mixins for transition workflows.

StatusBase

class django_transitions.workflow.StatusBase[source]

Base class for transitions and status definitions.

classmethod get_kwargs()[source]

Get the kwargs to initialize the state machine.

StateMachineMixinBase

class django_transitions.workflow.StateMachineMixinBase[source]

Base class for state machine mixins.

Class attributes:

  • status_class must provide TRANSITION_LABELS property and the get_kwargs class method (see StatusBase).

  • machine is a transition machine e.g:

    machine = Machine(
        model=None,
        finalize_event='wf_finalize',
        auto_transitions=False,
        **status_class.get_kwargs()  # noqa: C815
    )
    

The transition events of the machine will be added as methods to the mixin.

get_available_events()[source]

Get available workflow transition events for the current state.

Returns a dictionary:
  • transition: transition event.
  • label: human readable label for the event
  • cssclass: css class that will be applied to the button
get_wf_graph()[source]

Get the graph for this machine.

Django Admin Mixins

Mixins for the django admin.

class django_transitions.admin.WorkflowAdminMixin[source]

A mixin to provide workflow transition actions.

It will create an admin log entry.

response_change(request, obj)[source]

Add actions for the workflow events.