fastdev-django /

Filename Size Date modified Message
djaml → [d2f5324ef8dc]
724 B
119 B
113 B
1.7 KB
9.7 KB
2.2 KB
5.1 KB
8.0 KB

Fast Development Setup for Django

На русском

This project is a template for fast creation and development of Django websites. It contains all the tools that I know that allow fast coding, debugging and quality control.

When you add packages to buildout.cfg to be used in your project, any collaborator will get them just by running buildout script. No need to compare packages setups and versions, no need to use virtualenv.

With this setup, right away you have

  • extensions and a better shell
  • debugging tools (PuDB, Werkzeug, Debug Toolbar)
  • fast templating tools (HAML, SASS)
  • code quality tools (pyflakes, pep8)
  • useful packages (reversion, tastypie, annoying)

Credits for the initial contents of this package go to:


  • Python 2.5+
  • rubygems (for Sass)
  • libxml-dev, libxslt-dev
  • Database of your choice

How to install these libraries in Ubuntu:

sudo apt-get install libxslt-dev python-dev rubygems

All the other packages are bundled in the buildout script.


Clone the project:

hg clone yourproject
rm yourproject/.hg/hgrc

If you want to use CoffeeScript, read section "CoffeeScript" below.


cd yourproject
make run

Changed packages in buildout.cfg? Updated django.po in locales? Just stop the server and do make run again. The make shell_plus command is also smart and can re-build bin/django should you change the dependencies in buildout.cfg.

Read "Makefile and Less Keyboard Banging in Shell" for more information.

Important: in this environment, use bin/django instead of It's a script, assembled by buildout, that connects the project environment packages.



Installs zc.buildout script.

  • IPython and django-extensions

A better Python shell with code completion and scripting. The extensions package adds shell_plus command that runs IPython. There's a shortcut for it:

make shell_plus
  • PuDB

A debugging environment for Python, which looks like the good old QBasic or Borland IDEs from the '80-s.

To use it, add this line in the code where you need to debug:

import pudb; pudb.set_trace()
  • django-debug-toolbar

A toolbar that is embed into pages that shows you the list of rendered templates and their contexts. Enable its middleware and see a clickable label on the right in pages.

  • HamlPy

An elegant markup language that transforms into HTML. HamlPy implements HAML and a similar notation for Django template language:

- extends 'base.html'
- load i18n
- block body
        - trans 'Hello'
            - for item in menu
                    %a{'href': "{% url item.get_absolute_url %}",
                        'title': "{{ item.title }}"}=
                    = item.description

        - trans 'See you'
  • Django Compressor and Sass

Compressor can be used to transform and compress CSS and JS on the fly. Here it is used to convert SASS stylesheets in valid CSS. Usage (Haml notation):


- compress css
    %link{'href': '{{ STATIC_URL }}css/screen.sass',
          'rel': 'stylesheet', 'type': 'text/sass',
          'media': 'screen,projection'}
- endcompress

Sass stylesheet screen.sass:

@mixin border-radius ($radii)
    -webkit-border-radius: $radii
    -moz-border-radius: $radii
    -ms-border-radius: $radii
    -o-border-radius: $radii
    border-radius: $radii

    background: #88f
    +border-radius(1.5em)  // will expand in rules for all vendors

A not included feature: it can parse script tags in the page, open the JS files, minify them and pack into one single file.

  • CoffeeScript

If you want to use CoffeeScript, do the following:

  • edit Makefile and uncomment the line run: bin/coffee
  • set USE_COFFEE_SCRIPT = True in
  • if you use Ubuntu, make sure curl is installed (by default it is not):

    sudo apt-get install curl

You DON'T NEED Node.js, nor npm for this project to run CoffeeScript. Buildout will install them automatically. This makes it easier to deploy in web hosting.

  • Webfaction

To make a WSGI script for Webfaction hosting, run

make webfaction

In the project root the <project name>.wsgi script will be created. (Project name is set in buildout.cfg.)

Updated packages in buildout.cfg? Just do make webfaction again. Make will see that Django has to be re-installed with Buildout.