Setup Django WorkFlow Application


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:

Setup a Survey Web Site with Python & Django


This document shows how to setup a survey web site using python 2.7 and django 1.4. We do not need to use web server software such as IIS or Apache while python can start web server service itself. This survey web site can run under window and linux env provide that it has python. I will show its setup steps as below.

Step 1.

Download the program source code “” from web site and unzip it to a computer with python 2.7.

Step 2.

Under the django-survey-master directory, run the command $ pip install -r requirements.txt to install django.

Step 3.

Setup the survey database as command $ python syncdb , which you need to input a username and password.

Step 4.

Start the survey server as command $ python runserver ,as below screen dump:


Step 5.

Setup a survey as below screen dump with link :



Step 6.

Browse the survey web site to fill-in a survey as below link :



Bonus of a problem solving

Problem 1: The Survey web site is with link localhost:8000 and in its computer and that works fine. However, it cannot be accessed from other computer in the same network.

Solution 1: Start the Web Site Server with its own ip address, such as $ python runserver; then other computers in the same network can access it with link

Problem 2: If you have problem of running, it comes out a error message “Admin Site: TemplateDoesNotExist at /admin/ …”

Solution 2: Force to re-download django with command:

pip install -r requirements.txt --ignore-installed --force-reinstall --upgrade --no-cache-dir

使用AOFAX传真系统 – 进行无纸化签审管理


1.目的:为了实现公司无纸化办公的需求,以实现提高工作效率,降本节支的目的。 Read More