Django Installation and Environment Setup | W3schools

The environment for Django includes installation and setting up of Django, Python, and a database. Along with that, you will be required to have a web server setup as the framework deals with the web application.

Also Read: Django – Advantages and Disadvantages

Step 1: Installation of Python

Before we proceed any further, you need to install and set up Python on your system as the framework of Django is purely written in Python itself. The latest version of Django supports Python 2.6.5 and any higher version of it. In case you are a latest Linux or Mac OS X user then you need not go through the Python installation process. You can type in python as the command on the terminal or the command prompt as it will help you to check whether Python is installed on your system or not. The output should appear somewhat like the following otherwise you need to install Python.

    $ python
    Python 2.7.5 (default, Jun 17 2014, 18:11:42)
    [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2

You can download the latest version of Python from its official website. Here is the exact link from where you can get the latest version of Python:


Step 2: Installation of Django

The process of installation of Django is quite easy but it varies from one operating system to another. Python being a platform independent language supports Django to have only one package that is operable for any operating system. To download the latest version of Django, you can visit their official website or click over here:

Django Installation for Unix/Linux and Mac OS X:
If you are a user of Unix/Linux or Mac OS X then there are two ways available for you to install the Django framework.

* Use of package manager provided by your operating system. Otherwise, you can go for easy_install or pip, if these are already available on your system.

* You can also install Django manually. This needs to be done by visiting the official archive of Django.

In this tutorial, we will be helping you to install it using the second option as the first varies with your varying OS distribution. Well, before we jump to the next step, note that you need to be very careful while choosing the version of Django if you are going with the first option.

1. Now, considering that you have already got your archive from the link provided above. The archive must look somewhat with the name: Django-x.xx.tar.gz.


2. Extract this archive and start installing it.
    $ tar xzvf Django-x.xx.tar.gz
    $ cd Django-x.xx
    $ sudo python install

  • You can even test your installation by running the following command on your system’s terminal or command prompt.

    $ –version

The successful installation will be prompted by the console in the form displaying of the current version of the Django.

Note: There are some versions that won’t support the above command of $ –version. In that case, remove the extension of .py from the command, which makes it $ django-admin –version.

Django Installation for Windows OS:
Make sure that your Django archive and Python is already installed on your system.
Start with PATH verification.

  1. For Windows 7, make sure that PATH system variable has the value of the PATH as:

Here, you might need to change the Python version.

2. Extract the Django archive. Use the following command:
    c:\>cd c:\Django-x.xx

  • Now, for the installation of Django framework, you need to run the given command. But to use this command on the cmd, you need to have access to administrative privileges.

     c:\Django-x.xx>python install

3. To test the successful installation, type in the following command on the command prompt.
     c:\>python -c “import django; print(django.get_version())”

If your screen prompts the current version of Django then the installation has been successful.

Well, you can also perform this last step by typing in the following commands on the command prompt:
     c:\> python
     >>> import django
     >>> django.VERSION


Step 3: Database Setup

Django supports several important database engines, you can set up any of them.

* MySQL –
* PostgreSQL –
* SQLite 3 –
* Oracle –
* MongoDB –
* GoogleAppEngine Datastore –

You can install your database by visiting the links provided in front of their respective databases.

Note: MongoDB and GoogleAppEngine Datastore are NoSQL databases.

Step 4:

Web Server
Django framework supports a light-weight web server to test all your developed web applications. You need not configure this light-weighted server as it is already configured. Another important fact about this web server is that it restarts itself whenever you modify your code. This framework also supports other often used web servers (such as Apache, Lighttpd). We will discuss them as we move forward.