Home > programming > Use multiple Django versions for development

Use multiple Django versions for development

September 23rd, 2009

To use multiple Django versions for development, you will need virtualenv. Virtualenv is a sandbox that allows you to use different versions of Python in your development machine.  It is a tool to create isolated Python environments.

I have been using Django 1.1 beta on my projects.  Just recently, I needed to use Django 1.0 for a new project.  Of course there were major differences from Django 1.0 versus Django 1.1 which could cause headaches.

An example is that Django 1.0 uses this on its urls.py:

(r'^admin/(.*)', admin.site.root)

while Django 1.1 uses this on its urls.py:

(r'^admin/', include(admin.site.urls))

So, inorder to use multiple Django versions for development on your machine, you will need:

Create a virtualenv directory.  This is your working directory for the particular Django version:

$ virtualenv --no-site-packages --unzip-setuptools project-env

Create a requirements.txt to list your required Python applications:


Remember to change the 1.0.3 with any Django release version that you want for the virtual environment.

Install your project’s required python applications:

$ pip install -E project-env -r requirements.txt

If you encounter errors in one of the above packages, try installing one package at a time by editing your requirements.txt like this:

# install yolk first
$ pip install -E project-env -r requirements.txt

… edit requirements.txt again…

# install django
$ pip install -E project-env -r requirements.txt

Activate your virtual environment:

$ source project-env/bin/activate

This will change your shell path to show you are inside a virtual environment, and it looks like this:

(project-env) $

Yolk is used to list installed packages in your virtual environment:

(project-env) $ yolk -l

Create a django project:

(project-env) $ cd project-env
(project-env) $ django-admin.py startproject <project name>

And you are done!


To verify which Python version you are using (your global Python packages directory or your virtual Python’s packages directory):

(project-env) $ which python

To verify which django-admin.py you are using:

(project-env) $ which django-admin.py

To de-activate your virtual environment:

(project-env) $ deactivate

Happy Coding!

List of related articles on myListBoard.com:

Author: Cyril Pauya Categories: programming Tags: , , ,
  1. April 5th, 2010 at 19:02 | #1

    Many thanks to Jesumer “Bong” Escat for testing this guide. He spent 6 hours trying to make it work… he could have finished it sooner with just one line of command…

    $ sudo apt-get install python-dev libpq-dev

    I have updated the post to reflect this.


  2. April 6th, 2010 at 09:21 | #2

    Great! It helps me a lot.

  3. December 6th, 2011 at 10:46 | #4

    I was working on Django latest version. Do you have several resource on how to include CSS and Jquery i mean these are both external file in my css as embedded and inline it works fine but when i use it externally I got an error.. visit caraga forum website caragadatacenter

  4. July 29th, 2015 at 17:55 | #5

    Use http://admin-ahead.com/cPanel-Plugins/Admin-Ahead-cPanel-Django-Hosting-plugin.html, which allows for setup multiple python and django versions and the ability to control python module installation at the user level, instead of server-wide or administrator intervention.

  1. No trackbacks yet.