Graham King

Solvitas perambulum

Contributing to Django: quickstart

Instructions on how to setup a development environment to work on Django core, for example to review proposed patches, and prepare your own.

pip and virtualenv

Make sure you have pip, virtualenv, and virtualenvwrapper installed. On Ubuntu:

sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper

Edit your .bashrc and add this line ABOVE any mention of /etc/bash_completion

source /usr/local/bin/

Close your terminal and re-open.


Create a virtualenv for your Django development, and switch into it (your prompt should change):

mkvirtualenv --no-site-packages django-dev

Install system packages:

sudo apt-get install libmemcached-dev

# For MySQL
sudo apt-get install libmysqlclient-dev

# For PostgreSQL
sudo apt-get install libpq5

# Or neither of the above for SQLite only

Download a list of requirements:

wget -O /tmp/requirements.pip

This puts these lines in /tmp/requirements.pip. Edit it if you’re not using MySQL. If this post is old, check the latest list of Django dependencies:

Ask pip to install all that for you:

pip install -r /tmp/requirements.pip

You can delete /tmp/requirements.pip after it completes. Finally setup some helpful things:

vim bin/postactivate    # Replace vim with your favorite editor

Paste these lines into postactivate:

cd ${WORKON_HOME}/django-dev/src/django
export DJANGO_SETTINGS_MODULE=test_sqlite

And we’re done:


Run the tests

workon django-dev
cd tests

At time of writing there’s just over 4000 tests, and it takes 5 – 10 minutes to run them all. As you’re on SQLite you’ll see some ‘s’ and ‘x’ characters representing skipped tests (mysql and postgresql specific ones) and expected failures (features SQLite doesn’t support).

Make a patch

Hack away on the code, then:

cd ${WORKON_HOME}/django-dev/
svn diff > my_ticket_number.diff

You’ll most likely need a very simple Django project to try out your contributions before you share them.

Stay current

Django changes all the time. To checkout the latest version:

workon django-dev
svn update

Happy Contributing!