Install Django with Git

Published 30th April 2008

Although Brian Rosner did a very good Screencast on installing and using Git with Django, there are sadly no Show Notes available. This makes installing Django from Git a quite time-consuming task, if you haven't memorized the commands.

While writing down the commands for further use, I noticed that there's a faster way than cloning the official SVN repository by using an unofficial Git mirror. Later on, I wrote a small Bash script to automate the Django- from-Git installation, which you can download below.

Official SVN repository

First, clone the repository with:

git svn clone -s http://code.djangoproject.com/svn/django django

navigate to the django folder and run:

git gc

to cleanup unnecessary files and optimize the local repository. Finally, reset the master branch to point to trunk:

git reset --hard origin/master

Git mirror

Instead of going through the time-consuming task of cloning the official SVN repository, there's an faster and easier way. Matthias Kestenholz was so kind to set up a Git mirror for Django, which is updated hourly.

Just use the git clone command, as with any other Git repository:

git clone git://spinlock.ch/pub/git/django/django.git django.git

Bash script

To save some time on the next "Django from Git" installation, I wrote a simple Bash script to automate this task.

The script will clone the unofficial Git mirror in a folder called django.git and create the necessary symbolic links to install Django:

  1. django folder to the python site-packages directory.
  2. django-admin.py file to a directory on the system path (the script uses /usr/bin).

Download django-git-install

After the download, you need to make the script executable:

chmod u+x django-git-install.sh

The script expects the installation directory as the first parameter:

Usage: django-git-install.sh target-directory

For example, to install Django into /usr/lib/django.git, execute:

sudo ./django-git-install.sh /usr/lib