Linking Workflow to a CRUD View
Attaching a workflow to a BaseCrudView is a single line. Once attached, the CRUD view handles everything — setting initial status on create, exposing available transitions in the detail view, and wiring WorkflowStatus on the frontend.
Attach the Workflow
In your views.py, import the workflow class and assign it:
from ...packages.crud.base import BaseCrudView
from .tables import PatientTable
from .forms import PatientForm
from .workflow import PatientWorkflow
class PatientCrudView(BaseCrudView):
page_title = "Patients"
add_btn_title = "Add Patient"
table = PatientTable
form = PatientForm
workflow = PatientWorkflow # ← one line
What This Does Automatically
| Behaviour | Without workflow | With workflow |
|---|---|---|
| Record creation | No status set | on_create_status is assigned |
| Detail view | No status shown | Current status badge shown |
| Available actions | Only row actions from table | Row actions + transition buttons |
| Transition log | Nothing | WorkflowTransaction record created per transition |
Showing Status in the Table
Add a StatusCol to your table class to display the current status in the list:
from ...packages.crud.table.base import ModelTable
from ...packages.crud.table.column import ModelCol, StatusCol
class PatientTable(ModelTable):
name = ModelCol(display_as="Name", sortable=True, searchable=True)
status = StatusCol(display_as="Status") # ← shows workflow status badge
class Meta:
model = Patient
StatusCol automatically reads the record's current workflow status and renders it with the colour defined in Meta.statuses.
Showing Tags in the Table
If your workflow defines tags, add TagsCol:
from ...packages.crud.table.column import ModelCol, StatusCol, TagsCol
class PatientTable(ModelTable):
name = ModelCol(display_as="Name")
status = StatusCol(display_as="Status")
tags = TagsCol(display_as="Tags") # ← shows enabled tags
class Meta:
model = Patient
Frontend — WorkflowStatus Component
On the frontend, WorkflowStatus renders the current status and available transition buttons for the record:
import { WorkflowStatus } from '@zango-core/crud/table';
<WorkflowStatus
apiUrl={`/patients/?object_uuid=${objectUuid}`}
onStatusChange={() => refetch()}
/>
This is included automatically in the default CrudHandler detail drawer. If you're building a custom detail page, add it explicitly.