[Django Tutorial] How To Install Django Framework? HelloWorld Django!

This is second blog tutorial as a part of our tutorial Python Django Tutorial for Beginners. On our first post we setup a python Virtual Environment using Virtualenv. It was a basic yet preferred step to start building an application on Python. So create your virtual environment first and you may continue with our second blog tutorial about Installation of Django Framework

Django Installation

Once the virtual environment is setup and enabled you can begin installing Django Framework which is yet another python module for developing Web application. On your command type the following command just to make sure that the Virtual environment that you activated is working:

pip freeze

If you see this information than pip is listing the packages in your VIrtualenv which means that python executable environment is all set and now you can install Django using following command:

pip install django

This will install the latest version of django framework. Once the installation is complete go check the packages installed with pip freeze and it will list the following:


This ensures that DJango is installed successfully. Now we can create a new project with the help of django administration. So on your terminal type the following: startproject projectname .

This creates your first django project on your localhost and now you can easily run it on localhost server via following command:

python runserver

Your Django project is now live in your localhost environment in following URL :

This is all for the basic Django Installation on your localhsot server. Next section guides you through the installation of required python modules which we will be using in upcoming steps:

  1. PostgreSQL Connector psycopg2
  2. gunicorn
  3. dj-database-url

PostgreSQL Connector

The command below installs the PostgreSQL connector psycopg2:

pip install psycopg2

During the installation you might face the error related with the module and error is displayed similar to below:

ERROR: Command "python egg_info" failed with error code 1 in /tmp/pip-install-6fqwh3o6/psycopg2/

In such case you can proceed with installation of the PostgreSQL connector binary with following command:

pip install psycopg2-binary

This will install PostgreSQL library.

Next Install gunicorn and dj-database-url which can be done with a single command:

pip install gunicorn dj-database-url

Next install Django crispy forms to use the features of user friendly easy to implement forms

pip install django-crispy-forms

Finally install pillow with the command:

pip install pillow

That is all with the installation of django framework and some necessary modules to move forward. Now after all of these module installation you can check your django project running on your localhost by running command:

python runserver