How To Install Django

2 min read

Django is a full stack open source web development framework written in Python that encourages rapid development and clean, pragmatic design. Since it's release in 2003 Django has proven to be one of the most efficient modern web frameworks. Over the years Django and Python are on an unstoppable train of success. If you are planning to begin your journey as a web developer it's the best MVC framework to start with. Read more about the origins of Django read: Django – Web Framework For Perfectionists.

In this article, we will go through the Installation process of Django.

Installing Django

As said, Django is a web framework written in Python, In order to install it first, you need to Install Python in your system. To check whether or not you have Python installed in your machine run this on your terminal.

python --version

Expected Output:

Python 3.7.2

The version may vary until this returns the version of a Python release without any error, you are good to go. If this returns an error, then you have to install Python first.

Using Python 3.x+ is highly advised because Django 2.0+ is strictly for Python 3

  1. How To Install Python On Windows
  2. How To Install Python 3 on Mac OS

After Python Installation we need to install virtualenv (Optional Prerequisite), this is not a dependency of Django, but it is advised to create separate virtual environments for different projects. By using virtual environments, applications can run in their own ‘sandbox’ in isolation of other Python applications.

To know more about the virtual environment and their installation procedure read: How To A Create Virtual Environment for Python

Once we have Python and virtual environment are in place we can proceed to create virtual environments for Django Installation this is not necessary but is recommended.

Creating Virtual Environment for Django

For Windows

cd Desktop
virtualenv django
cd django
Scripts\activate.bat

For Unix and Mac

mkdir django
cd django
python3 -m venv myenv
source django/bin/activate

Now your terminal should be prefixed with django, if not then go through the virtual environment guide again.

Once the virtual environment is activated, we can finally proceed to Install Django. We will use Pip package manager to install Django.

pip install Django

This will install the latest version of Django in our environment. keep patience It may take some time depending on your internet connection.

To install a specific version of Django you can specify it as follows.

 pip install Django==1.11

Verifying Django Installation

To verify the Django installation or to know the version of Django installed in your system execute this is terminal.

django-admin --version

This should return an official Django release version.

2.1.7

Now that installation is done, you may deactivate the environment.

deactivate

RecommendedHow To Create A ‘Hello, World!’ Application With Django


TOOLS

Latest Articles

Latest from djangocentral

Capturing Query Parameters of request.get in Django

In Django, the request object contains a variety of information about the current HTTP request, including the query parameters. Query parameters are a way to pass additional information in the URL and are used to filter or sort data. The request object p…
Read more →

2 min read

Understanding related_name in Django Models

In Django, related_name is an attribute that can be used to specify the name of the reverse relation from the related model back to the model that defines the relation. It is used to specify the name of the attribute that will be used to access the relat…
Read more →

2 min read