Install Python

Django is a Python web framework, thus requiring Python to be installed on your machine.

To install Python on your machine go to, and download a Windows MSI installer for Python. Once downloaded, run the MSI installer and follow the on-screen instructions. As of writing this article, there were two available versions of python: 2.7.11 and 3.5.1.

I chose Python 2.5.11 since there are still several software that doesn't support Python 3.x

After the installation is completed you need to add python path to your environment variable. So if you your installation path is c:\python27 then your PATH variable should be set like this:


Verify installation by executing python --version in a command line.

Install PIP

PIP is a package manager for python which will be used to install Django. To install, execute easy_install pip from a command line. This will install pip on your system. If that doesn't work for you, go to and download

Now run python to install pip. You may need to restart your system or command prompt to  confirm the installation. If you get an error like: 

'pip' is not recognized as an internal or external command

you need to make sure you have set the environment path correctly. Verify installation by executing pip --version in a command line.

Install Django

 To install django, execute pip install django from a command line. To verify installation, execute django-admin --version.


Creating a new Project in Django

To create a new project, browse to your project directory and execute, django-admin startproject myproject

 This will create myproject directory in your current directory.  Browse to this directory and run python runserver.

If everything works well, you should see a welcome page when you visit in your browser.

 Create a new app

An app is created to do something specific like logging, creating a voting system etc. A project can have multiple apps. To create a new app, type:

python startapp myapp

 This will create a new directory myapp inside the parent directory myproject

Setup Views

To write your first view, open myapp/ and add the following code to it:

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the myapp index.")

Setup Routing

To setup routes, create a new file inside myapp directory and paste the following into it:

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),

To make this work, you need to import this url file into the project file. Open the in the myproject directory and paste the following into it:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^myapp/', include('myapp.urls')),

To see it in action, re-run the server and browse to  http://localhost:8000/myapp. You should see the text, "Hello, world. You're at the myapp index."

That sure will make you happy. Now let's move forward to the next step.