How to Install Multiple Versions of Django in linux

In this post, we will discuss the installation of Django in Virtualenv. By using Virtualenv one can install different / multiple versions of Django in Linux machine like Fedora, Ubuntu even in Mac. If virtualenv is not installed already in the machine, check the previous post on “How to install Virtualenv in Linux”. After installing Virtualenv, follow the steps below.

To Install the latest version of Django(version 1.3)

Create a virtualenv folder called Django_V1.3 using the following command or copy and paste it.

virtualenv Django_V1.3

Now the Virtualenv folder is created and now, activate the Virtualenv by using the following command

source Django_V1.3/bin/activate


or

move to the Virtualenv directory

cd Django_V1.3

After moving to the Virtualenv directory activate the Virtualenv by using below command

source bin/activate

Once the Virtualenv is activated and it look like this (Django_V1.3)user@user-laptop:~$

Now, download Django1.3 from djangoproject.com to the current directory or use the following command which will automatically download Django1.3 to the current working directory

wget http://www.djangoproject.com/download/1.3/tarball/

Now, extract the tar file in the current working directory by right clicking and then by using the extract option or use the below command to extract it

tar -xvf Django-1.3.tar.gz

After extracting the tar file, change the directory to Django-1.3 or copy and paste the below command

cd Django-1.3

Now it will look like this

(Djangov_1.3)user@user-laptop:~/Djangov_1.3

To install the Django1.3

*Note – Don’t use sudo to install the Django because Django will not be installed under Virtualenv

The command used to install the Django is

python setup.py install

The installation takes few seconds. After installation process, check whether its working or not, by starting the Django server.

Steps to identify whether Django is working

Change the directory where you want to create a project. Now, create a dummy project called example or with any name. Use the command below to create a dummy project.

django-admin.py startproject example

After running the above command it will create a folder called example. Now, change the directory to example by using cd command.

cd example

Just type “ls” in the current working directory and you will find these files in the example folder  __init__.py,  manage.py,  settings.py,  urls.py .

Now, run the Django server by using the following commands

python manage.py runserver 8080

After running the server go to the browser and type localhost:8080 or http://127.0.0.1:8080/. It will show the message as “It Works”.

Django1.3 is successfully installed in the system. Now, to install another version just repeat the steps again from starting but change the Virtualenv folder name to its version number like Django_V1.2 or Django_V1.1 or Django_V1.0. So that, it will be easy to identify on which version you are working on.

Hope this will be helpful for you!!!

Enjoy installing and working on multiple versions of Django!

Related Posts Plugin for WordPress, Blogger...