django-xworkflows documentation¶
django-xworkflows is a django application adding xworkflows functionnalities to django models.
Getting started¶
First, install the required packages:
pip install django-xworkflows
In your settings.py
, add django_xworkflows
to your INSTALLED_APPS
:
INSTALLED_APPS = (
'...',
'django_xworkflows',
)
Define a workflow:
from django_xworkflows import models as xwf_models
class MyWorkflow(xwf_models.Workflow):
log_model = '' # Disable logging to database
states = (
('new', _(u"New")),
('old', _(u"Old")),
)
transitions = (
('get_old', 'new', 'old'),
)
initial_state = 'new'
And add it to a model:
from django import models
from django_xworkflows import models as xwf_models
class MyModel(xwf_models.WorkflowEnabled, models.Model):
state = xwf_models.StateField(MyWorkflow)
The state
field of MyModel
is now defined as a django.db.models.CharField
,
whose choices
and default
are configured according to the related
django_xworkflows.models.Workflow
.
Integration with django¶
After each successful transition, a save()
is performed on the object.
This behaviour is controlled by passing the extra argument save=False
when calling the transition method.
If the Workflow
has a definition for the log_model
attribute (as a <app>.<Model>
string),
an instance of that model will be created for each successful transition.
If the django_xworkflows.xworkflow_log
application is installed,
log_model
defaults to
TransitionLog
.
Otherwise, it defaults to ''
(db logging disabled).
This behaviour can be altered by:
- Setting the
log_model
attribute to''
- Calling the transition method with
log=False
(no logging to database) - Overriding the
db_log()
method of theWorkflow
. - Overriding the
log_transition()
method of theWorkflow
; this controls bothlog
andsave
behaviours.
Contents¶
- Library internals
- ChangeLog
- 0.11.0 (2017-02-25)
- 0.10.1 (2016-06-26)
- 0.10.0 (2016-02-15)
- 0.9.4 (2014-11-24)
- 0.9.3 (2014-06-04)
- 0.9.2 (2013-09-25)
- 0.9.1 (2013-08-14)
- 0.9.0 (2013-05-16)
- 0.8.1 (2012-11-30)
- 0.8.0 (2012-10-12)
- 0.7.1 (2012-09-10)
- 0.7.0 (2012-08-17)
- 0.6.0 (2012-08-02)
- 0.5.0 (2012-07-14)
- 0.4.5 (2012-06-12)
- 0.4.4 (2012-05-29)
- 0.4.3 (2012-05-29)
- 0.4.2 (2012-05-29)
- 0.4.1 (2012-05-29)
- 0.4.0 (2012-04-29)
- 0.3.1 (2012-04-15)
Resources¶
- Package on PyPI: http://pypi.python.org/pypi/django-xworkflows
- Repository and issues on GitHub: http://github.com/rbarrois/django_xworkflows
- Doc on https://django-xworkflows.readthedocs.io/
- XWorkflows on GitHub: http://github.com/rbarrois/xworkflows
- XWorkflows doc on https://xworkflows.readthedocs.io/