What is Django? Django is a powerful and fully-customizable web framework written in Python. Some websites like Instagram used it. Django has a rather unique concept: MTV (Model-Template-View), unlike most web frameworks. As you can see, there is no “controller” in Django. Django provides “View” to help developers implementing the controller’s jobs. “View” is the place for retrieving data from “Model” to be displayed on “Template”. What is “Template”, anyway? Templates are simply the front-end component. They used a templating language, a language that differs from Python itself. It is very simple, with basic programming logic like operator or loop. For example, you can make HTML files as templates, with template language on them.
So now, how to install Django? Quite simple. The steps are just simply:
- Install Python
- Install pip
- Install Django
Installing Python is very simple. But which version? I recommend version 2.7 since it worked perfectly on running Django.
On Windows, you can get the installer from here.
On ubuntu, you can run these commands:
sudo apt-get update sudo apt-get install python2.7
Once Python have been installed, you can install “pip” now.
Pip is a tool for installing and managing Python packages, including Django. Installing pip on ubuntu is very simple, just run this command:
sudo apt-get install python-pip
For windows, first you must add these paths into your environment variables “PATH”:
And then, run python-distribute script to install easy_install
Install pip with easy_install
The command for installing Django with pip is very simple:
pip install django
To install Django with specific version, run this command:
pip install django==1.4.2
You can replace 1.4.2 with any Django version, such as 1.3.1 or 1.5.0.
Remember that you must use sudo for installing python packages with pip on UNIX-based operating systems.
Verify Django Installation
To make sure if Django is properly installed, you can simply import Django and then view the version, like this:
$ python >>> import django >>> django.VERSION (1, 4, 2, 'final', 0)
Congratulations! Now you can start making your Django projects!