Skip to main content

Reusable workflow library for django

Project description

Reusable workflow library for Django

Needle and thread to tie simple CRUD views and python functions in a complex business process.

Designed for:

  • Back office automation

  • People collaboration software

  • Business process implementation


  • Simple integration with django views/signals/models

  • User and background tasks support

  • Complex Split/Joins for parallel task execution

  • Boilerplate urls registration and permission checks handling



About hundred lines of code required to make this process life with django-viewflow and django class based views.


django-viewflow requires Python 3.3 or greater, django 1.6:

pip install django-viewflow

For installing Viewflow-Pro with Python 2.7 support:

pip install django-viewflow-pro  --extra-index-url<licence_id>/simple/

Or inside of your project by adding the following statement to requirements.txt:


And add it into INSTALLED_APPS settings


Quick start

See the introduction video or read below:

Let’s define basic Hello Process where one could start hello world request, another person approves it, and as soon as the request is approved it should be send into background.

Start with process database model definition

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

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

Define the actual task that says Hello to the World in

import os

from celery import shared_task
from viewflow.flow import flow_job

def send_hello_world_request(activation):
    with open(os.devnull, "w") as world:

To make the above code work just put the following flow definition in module from your django application.

from viewflow import flow, lock
from viewflow.base import this, Flow
from viewflow.contrib import celery
from viewflow.views import StartView, ProcessView

from . import models, tasks

class HelloWorldFlow(Flow):
    process_cls = models.HelloWorldProcess
    lock_impl = lock.select_for_update_lock

    start = flow.Start(StartView, fields=["text"]) \
        .Permission(auto_create=True) \

    approve = flow.View(ProcessView, fields=["approved"]) \
        .Permission(auto_create=True) \

    check_approve = flow.If(cond=lambda p: p.approved) \
        .OnTrue(this.send) \

    send = celery.Job(tasks.send_hello_world_request) \

    end = flow.End()

Flow class contains all urls required for the task processing.

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

urlpatterns = patterns('',
    url(r'^helloworld/', include([
        url('^$', viewflow.ProcessListView.as_view(), name='index'),
        url('^tasks/$', viewflow.TaskListView.as_view(), name='tasks'),
        url('^queue/$', viewflow.QueueListView.as_view(), name='queue'),
        url('^details/(?P<process_pk>\d+)/$', viewflow.ProcessDetailView.as_view(), name='details'),
    ], namespace=HelloWorldFlow.instance.namespace), {'flow_cls': HelloWorldFlow}))

Your Hello World process is ready to go. If you run the development server locally, go to http://localhost:8000/helloworld/ and step through the workflow.

Next, you can see how to define custom views, and meet other concepts of django-viewflow at

More examples are available in the tests/examples directory.


Viewflow is an Open Source project licensed under the terms of the AGPL license - The GNU Affero General Public License v3.0

Viewflow Pro has a commercial-friendly license allowing private forks and modifications of Viewflow. You can find the commercial license terms in COMM-LICENSE. Please see FAQ for more detail.

Latest changelog

0.8.0 - 2014-12-02

  • Development of viewform and karenina projects no longer opensourced

  • Refactor fsm from task model to activation classes

  • Generic admin actions for changing tasks state

  • Support for view tasks unassign/reassign

  • Allow tasks undo and cancel

  • Store error information for tasks


  • in 0.9.0 at January we going to extend documentation and improve task undo behaviour

  • 1.0.0 LTS estimated at March 2015 would have lifetime support same as django 1.6

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-viewflow-0.8.0.tar.gz (51.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page