Visual DSL framework for django
Clone or download
Latest commit c29dfd1 Oct 9, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin heroku fix Jan 3, 2018
business_logic version bump Oct 9, 2018
frontend semantic-ui: use cdnjs for icon font Sep 21, 2017
sites django-nested-admin instead django-nested-inline fixes #28 Oct 9, 2018
tests django-nested-admin instead django-nested-inline fixes #28 Oct 9, 2018
.codeclimate.yml Node.interpret() refactoring #19 Oct 25, 2017
.coveragerc ProgramArgumentField.get_title() Aug 11, 2016
.dockerignore docker Aug 11, 2018
.gitattributes .gitattributes Sep 25, 2017
.gitignore docker Aug 11, 2018
.gitmodules use https for submodule Dec 19, 2016
.landscape.yml .landscape.yml Oct 25, 2017
.style.yapf yapf added Oct 22, 2017
.travis.yml django 2+ support, django < 1.11 removed Sep 14, 2018
Dockerfile django-nested-admin instead django-nested-inline fixes #28 Oct 9, 2018
LICENSE.txt Aug 29, 2016 requirements.txt += djangorestframework Dec 4, 2015
Makefile docker Aug 11, 2018
Procfile heroku deployment Oct 8, 2017 django-nested-admin instead django-nested-inline fixes #28 Oct 9, 2018
README.rst version bump Oct 9, 2018
app.json heroku deployment Oct 8, 2017
docker-compose.yml docker Aug 11, 2018 dev scripts Nov 16, 2016 pep8: E501 line too long Oct 22, 2017 django 2+ support, django < 1.11 removed Sep 14, 2018
requirements.heroku.txt heroku fix Jan 3, 2018
requirements.test.txt fix for pip>=10 Jun 3, 2018
requirements.txt django-nested-admin instead django-nested-inline fixes #28 Oct 9, 2018 dev scripts Nov 16, 2016
setup.cfg setup.cfg += [pep8] Oct 23, 2017 fix for requirements.txt environment markers Sep 17, 2018
tox.ini django 2+ support, django < 1.11 removed Sep 14, 2018


travis-ci codeclimate codecov coverage MIT license python versions django versions pypi version pypi version status


If you are familiar with react/mobx and want to help us build awesome django-business-logic library, contact us at


Work on documentation in the process, see draft here.


The main goal of this project is to provide django site users (such as administrators or ordinal users) with ability to visually edit business logic layer. This library implements execution engine and code editor based on awesome blockly library. See screenshots.


Please note that this software is still Alpha/Beta quality and is not recommended for production use. The library is currently in active development and any API may be changed. Migration history for models is not supported now. Some internal objects are world writable!


This library requires the following:

  • Python (2.7, 3.4, 3.5, 3.6)
  • Django (1.11, 2.0, 2.1) (for Django 1.8, 1.9, 1.10 use 0.4.13 version)
  • django-rest-framework 3.8+


Internally program code is stored as special django models such as NumberConstant, IfStatement, Assignment and so forth. Structure of syntax tree is held by class Node derived from treebeard.NS_Node. Operators and operands are linked with Node objects via django contenttypes system. Other details are briefly described below in sections Administrative setup and Execution

Docker demo

You can run demo app locally using docker:

docker build . -t django-business-logic-demo
docker run --rm -it -p 8000:8000 django-business-logic-demo

or using docker-compose:

docker-compose up

Also you can use prebuilt image:

docker run --rm -it -p 8000:8000 dgksu/django-business-logic:demo

Now you can login into django admin interface http://localhost:8000/admin/ with username test and password test.

Heroku demo

You can deploy demo app directly to Heroku to see the app live. Just click the button below. This will walk you through getting this app up and running on Heroku in minutes.



There are a few different ways you can install django-business-logic:

  • Use pip: pip install -U django-business-logic
  • Download the zipfile from the releases page and install it.
  • Checkout the source: git clone git:// and install it yourself.

Server setup

  1. Edit and add business_logic to your INSTALLED_APPS
    # ...
    'ace_overlay', # optional, for comfortable python functions editing
    'rest_framework', # optional, provided browsable API for this library handy development
    'django_filters', # ^^ same
    # ...
  1. Edit and include business_logic.urls
urlpatterns = (
  # ...
  url('^nested_admin/', include('nested_admin.urls')),
  url('^business-logic/', include('business_logic.urls')),
  # ...
  1. Make migrations
python migrate
  1. Collect static files
python collectstatic

Administrative setup

First you should define one or more ProgramInterface objects via django admin interface (http://localhost:8000/admin/business_logic/programinterface/).

Each ProgramInterface must contain one or more ProgramArgument objects. The ProgramArgument object represents one instance of django.db.Model derived class specified as django.contrib.contentypes.ContentType instance (e.g. for your custom Order model) and his keyword argumet name (e.g. order).

Each ProgramArgument object must contain one or more ProgramArgumentField which represents one field of django model (e.g. sum for Order object or for city field nested into Order DeliveryAddress model).

If you want to use system-wide references (e.g. your custom City or ProductCategory django model) and you define represented ProgramArgumentField you should register referenced model via django admin interface(http://localhost:8000/admin/business_logic/referencedescriptor/).

Next create one or more Program objects which must implements described ProgramInterface(e.g. named "On Order create" with "on_order_create" code field for programmatic access)

Visual Programming

After setup you can go to web editor interface (http://localhost:8000/static/business_logic/index.html), choose program interface, program, create and start editing your first program version.


You may inject execution engine call at arbitrary place of your code, such as custom, model.post_save methods, any django.dispatch.Signal handler or so on. Just instantiate appropriate ProgramVersion object and pass kwargs described in the ProgramInterface admin page to its execute() method . e.g.

from django.views.generic.edit import CreateView

from business_logic.models import Program

class OrderCreate(CreateView):
    def form_valid(self, form):
       order =
       program = Program.objects.get(code="on_order_create")
       program_version = program.versions.order_by("id").last()

ProgramVersion.execute() method can accept instance of business_logic.Context object. If this parameter omitted execute() method creates new instance of Context with default parameters.

It can be initialized by the following parameters:

  • log(boolean) - create execution log (default - False)
  • debug(boolean) - create special Execution object contained all variables passed to execute() method, ProgramVersion object, start and end execution times, and root of log objects if its created (default - False)

ProgramVersion.execute() returns the Context instance.


Many thanks to:


  • References support
  • Execution log viewer
  • Imported and editable via admin interface python functions
  • Lists and Loops
  • Implicit strong static typing
  • Visually editable functions and its libraries
  • Two-dimensional constant tables (matrices)
  • Code sharing
  • Pure python code generation for execution speedup

Library Development

Backend development environment


Virtualenv is probably what you want to use during development. Once you have virtualenv installed, just fire up a shell and create your own environment.

virtualenv venv
source venv/bin/activate
pip install -r

Installing test data

python migrate
python loaddata sites/dev/fixtures/data.json

Running backend dev server

python runserver

An instance of django dev server will be listening on http://localhost:8000/ . Now you can login into django admin interface http://localhost:8000/admin/ with username test and password test.

Frontend development environment

Fronted source files located under frontend folder.

cd frontend

Installing dependencies

npm install

Running webpack dev server

npm run server:dev:hmr

Now webpack dev server will be listening on http://localhost:3000/ .

Building frontend files

npm run build:prod

Running tests

Running backend tests

python test

Test it all

You need to know at least one command; the one that runs all the tests: