Introduction
Django is a free and open source web framework written in Python programming language that helps developers build complex web applications easily and quickly.
Initial Set Up
Before we get down to the installation of Django, we need to equip the server with Python. The common method of installation is by creating an isolated Python environment called virtualenv. This is to ensure that the python projects will not be affected by the changes made to the overall virtual server. Another advantage with virtualenv is that it doesn’t require root access for its installation or maintenance.
Once the virtualenv is in place, we can install Django within that using Pip. Pip is a tool used for installing, upgrading and removing python packages easily. Here, in this tutorial since we are using Ubuntu, Pip is installed through apt-get as given below:
sudo apt-get install python-pip
Now, for installing Python, use the command below:
curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
You will have to create a new virtualenv. You can do that by:
python virtualenv.py example_env
Once it is done, you can activate the virtualenv to make sure all the changes and installations will be done within that environment. Here I am using the name example_env. You can replace it with your values.
. example_env/bin/activate
Installing Django
Now that we are done with all the initial set up require for Django, we can easily install Django using Pip tool.
pip install Django
Django will be installed on your droplet.
In case if you wish to make changes to your version of Django or any of Python packages, you can achieve that using the commands below. These commands are quite self-explanatory.
pip install --upgrade Django pip uninstall Django