Use multiple Django versions for development
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:
- internet connection
- setuptools
- pip
- virtualenv
fix for psycopg2 installation errorCompiling psycopg2 on Ubuntu- $ apt-get install python-dev libpq-dev
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:
Yolk Django==1.0.3
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 Yolk #Django==1.0.3
$ pip install -E project-env -r requirements.txt
… edit requirements.txt again…
# install django #Yolk Django==1.0.3
$ 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!
Bonus:
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:



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-devI have updated the post to reflect this.
Great! It helps me a lot.
Great! Glad it helped you too.
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