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
Package on PyPI: http://pypi.python.org/pypi/django-xworkflows
Repository and issues on GitHub: http://github.com/rbarrois/django_xworkflows
XWorkflows on GitHub: http://github.com/rbarrois/xworkflows
Release files for django-xworkflows 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_xworkflows-1.0.0.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_xworkflows-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 32.2 kB
Release files / django_xworkflows-1.0.0.tar.gz
| Download URL | django_xworkflows-1.0.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b233b5244fb864f95ba935bd3f2214c55600db6294dbca544a6f9eb14918fb06
|
|
BLAKE2b-256 checksum How to use checksums |
6658715dc4cd9ddf05f24e53220ca11261c868fe34284f429dc9942340f4c894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|
Release files / django_xworkflows-1.0.0-py2.py3-none-any.whl
| Download URL | django_xworkflows-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
dc7c68e786b5392abf556f6dcd7182e947f77d1a964043868d4d8615fdd760e4
|
|
BLAKE2b-256 checksum How to use checksums |
46288fa4acad62e6951ad102f639f776e4e7e20033787d805fd0d031672886d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|