Recently, I studied how to setup a work flow program using python django. Believe me, Python Diango can provide you a high quality work flow web application. Let’s say I would like a simple workflow application as below diagram. I will show you how to setup the application as below instruction, and I will also show you the screen dump examples of running the application.


Step 1. Prerequisition

This Work Flow Program requires Python 3.3 or greater, and django 1.6 or 1.7. I recommend you to setup under virtual environment. Setup the following python plug-in by running the following command:

$ pip3 install Django==1.7.1
$ pip3 install WebOb==1.4
$ pip3 install WebTest==2.0.16
$ pip3 install amqp==1.4.6
$ pip3 install anyjson==0.3.3
$ pip3 install beautifulsoup4==4.3.2
$ pip3 install billiard==
$ pip3 install celery==3.1.16
$ pip3 install django-fsm==2.2.0
$ pip3 install django-viewflow==0.7.0
$ pip3 install django-webtest==1.7.7
$ pip3 install kombu==3.0.23
$ pip3 install mock==1.0.1
$ pip3 install pytz==2014.9
$ pip3 install singledispatch==
$ pip3 install six==1.8.0
$ pip3 install waitress==0.8.9

Step 2. Create a standard django project and application

Run the following command:

$ startproject demo .

$ ./ startapp helloworld

$ mv helloworld/ demo/

Step 3. Edit or Create the following files

3.1 edit demo/



3.2 edit demo/

from django.conf.urls import patterns, include, url
from django.contrib import admin
from viewflow import views as viewflow
from .helloworld.flows import HelloWorldFlow

urlpatterns = patterns(
            url(‘^$’, viewflow.ProcessListView.as_view(), name=’index’),
            url(‘^tasks/$’, viewflow.TaskListView.as_view(), name=’tasks’),
            url(‘^queue/$’, viewflow.QueueListView.as_view(), name=’queue’),
                viewflow.ProcessDetailView.as_view(), name=’details’)],
            {‘flow_cls': HelloWorldFlow}),
    #url(r’^flows/’, include(viewflow.urls)),
    url(r’^admin/’, include(,
    url(r’^accounts/login/$’, ‘django.contrib.auth.views.login’, name=’login’),
    url(r’^accounts/logout/$’, ‘django.contrib.auth.views.logout’, name=’logout’),

3.3 create demo/

import os
from celery import Celery

from django.conf import settings

os.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘demo.settings’)

app = Celery(‘tests’)

app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

3.4 create demo/helloworld/

from viewflow import flow
from viewflow.base import Flow, this
from viewflow.contrib import celery

from . import models, views, tasks

class HelloWorldFlow(Flow):
    process_cls = models.HelloWorldProcess

    start = flow.Start(views.CreateRequestView) \

    approve = flow.View(views.ApproveRequestView) \

    is_approved = flow.If(lambda p: p.approved) \

    send = celery.Job(tasks.send) \

    end = flow.End()

3.5 edit demo/helloworld/

from django.db import models
from viewflow.models import Process

class HelloWorldProcess(Process):
    text = models.CharField(max_length=250)
    approved = models.BooleanField(default=False)

3.6 edit demo/helloworld/

from demo.celery import app as celery_app
from viewflow.flow import flow_job

def send(activation):

3.7 edit demo/helloworld/

from django.views import generic
from viewflow import views as flow_views

class CreateRequestView(flow_views.StartViewMixin,
    fields = [“text”]

    def get_object(self):
        return self.activation.process

class ApproveRequestView(flow_views.TaskViewMixin,
    fields = [“approved”]

    def get_object(self):
        return self.activation.process

Step 4. Start the Application Server

Run the following Command:

./ createsuperuser –username=admin –
( setup admin password )

./ makemigrations

./ migrate

Start the following celery in another virtual env

celery -A demo worker -l info

Start the application server:

./ runserver

Step 4. Run the Application from browser

Admin Logon

WorkFlow Application Logon

Step 5. Screen Dump Example of running the WorkFlow Application




Reference Document Link:

Leave a Reply

Your email address will not be published.

Solve : *
17 − 2 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>