I want to build a Django solution which workflow can be defined and changed on the fly, hopefully by updating a BPMN diagram without having to change the source code and redeploy.
Despite such a feature has been around for quite a while in Java (i.e. Camunda and Bizagi), in the context of Django it seems to have not sparked the same interest since the usual places where I searched did not provide any satisfactory answers. The answers to a similar question from 2011 revealed that the term "workflow" is so wide that could mean many things. However, after some scrutiny it seems to boil down to two approaches: Django-based workflows and BPMN engines.
The problem with Django-based workflows listed in Github and Django packages is that the most popular/stable (for example Viewflow or ActivFlow) provide some kind of framework to ease the implementation of your states and transitions but, at the end of the day, you need to code changes by hand each time that the stakeholders change their mind about the process flow. The most promising option found at the awesome Django list was django-river which at least stores the states and transitions of the workflow as Django models in the database, so you can make changes on the fly.
The other big approach is BPMN engines. After messing around with several Python-pure (non Django) options, I manage to get SpiffWorkflow working using bpmn_dmn. Now I can load .bpmn diagrams and .dmn tables made with Camunda Modeler and run them through the engine to get a final event based on some parameters.
from bpmn_dmn.bpmn_dmn import BPMNDMNXMLWorkflowRunner
filename = 'rates.bpmn'
runner = BPMNDMNXMLWorkflowRunner(filename, debugLog='DEBUG', debug=False)
data = {'size': 150, 'type': 'SH', 'country': 'US'}
runner.start(**data)
res = runner.getEndEventName()
print(res)
This is straightforward and useful enough to run small workflows that do not require human intervention. However I still need to bridge the gap between a workflow loaded from a .bpmn diagram definition and the transitions between Views/Forms/Model states inherent to a Django solution.
So far my best option seems to be to translate the workflow specification from SpiffWorflow into states/transitions records in the django-river models database, but I wonder whether there is a better option out there.