Library to plug xworkflows into django models.
Python Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dev Support Django 1.10. Feb 24, 2017
django_xworkflows Back to development: 0.12.4 Feb 6, 2018
docs Back to development: 0.12.4 Feb 6, 2018
tests Fix issue with Django qs.only() Feb 5, 2018
.flake8 Update packaging Feb 24, 2017
.gitignore
.travis.yml testing: Improve travis performance. Jan 29, 2018
ChangeLog Update MANIFEST.in+ChangeLog following docs move. Jun 26, 2016
LICENSE
MANIFEST.in [pkg] Include Makefile in sdist tarballs Sep 3, 2017
Makefile
README.rst Convert readthedocs links for their .org -> .io migration for hosted … Jun 15, 2016
manage.py Move migration helper code. Nov 30, 2012
requirements.txt Update packaging Feb 24, 2017
requirements_dev.txt [packaging] Add zest.releaser. Aug 30, 2017
requirements_test.txt
setup.cfg
setup.py
tox.ini

README.rst

Django-XWorkflows

https://secure.travis-ci.org/rbarrois/django_xworkflows.png?branch=master Latest Version Supported Python versions Wheel status License

Use XWorkflows along with Django models.

Django-XWorkflows allow to bind a Django model to a workflow, with a few extra features:

  • Auto-save after transitions
  • Log each action into the database

Define a workflow and add it to a model:

from django import models
from django_xworkflows import models as xwf_models

class MyWorkflow(xwf_models.Workflow):
    states = (
        ('new', _(u"New")),
        ('old', _(u"Old")),
    )
    transitions = (
        ('get_old', 'new', 'old'),
    )
    initial_state = 'new'

class MyModel(xwf_models.WorkflowEnabled, models.Model):

    state = xwf_models.StateField(MyWorkflow)

Use the workflow:

>>> obj = MyModel()
>>> obj.state  # Defaults to the initial_state
State('new')
>>> # Perform a transition
>>> obj.get_old()
>>> obj.state
State('old')
>>> # Object was saved to the database
>>> obj.pk
1
>>> # Logs were saved to the database
>>> xwf_models.TransitionLog.objects.all()
[TransitionLog(MyModel: new -> old at 2012-04-14T12:10:00+0200)]

Links