Wednesday, April 1, 2015

Installing and testing Django

Django is a web development framework for python. It eases your development time and makes web development a real joy. In this article I'll show you how to install Django and test it, given you already have python installed in Linux. Installing Django is a simple step and it's a single command.
$ sudo pip install django
It assumes you have python-pip module installed. If not install it using the following command.
sudo apt-get install python-pip        // In Debian Linux/Ubuntu

sudo yum install python-pip         // In Red Hat and Fedora
After installing you can check whether everything is setup properly. Use the following commands.
$ python
Python 2.7.8 (default, Nov 10 2014, 08:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.VERSION
(1, 7, 7, 'final', 0)
Let's start off with setting up a default project to see the Django in work.

Create a directory of your choice. Say $HOME/DjangoProjects.

Navigate to that directory and issue the following command.
$ startproject mysite     // Here 'mysite' is your project name
This will create a directory called mysite, inside which you'll find a file named and another directory named 'mysite' which in turn contains four files; namely,,, urls,py and

Let's not bog down into details of what these files are all about. You can find detailed information in the Django web site

Let's start the Django's test server for this default site. (This server is merely for testing and not recommended to use in production). Type the following to start the server.
$ python runserver 9876

This should start run the server on port 9876. To see the welcome page, open a browser and navigate to

Hope this was a good starting point for you to learn Django. Enjoy working with Django.