Django is a free and open-source web framework for python. It is very fast & allows rapid development by developers to create a website with less time as well as efforts. Django is highly scalable & is also very secure, it allows developers to avoid common mistakes leading to serious security threats like XSS, SQL injection, CSRF, etc.

Recommended Read: Simple way to install Git on CentOS/RHEL

Also Read: Complete guide on Git Commands for Beginners

All these features have lead Django to being the most widely used framework. It is now being used by many major organizations to power their websites, like for example Pinterest, Firefox, NASA, Instagram, BitBucket, etc. In this tutorial, we will learn to install Django on Ubuntu.


Install Django on Ubuntu

To install Django on Ubuntu servers, we can use either of the following three methods mentioned below,

1- Install using apt

2- Using PIP

3- Using the Github Packages


1- Install using apt

Django packages are maintained by the default Ubuntu repositories & can be installed using the Ubuntu package manager i.e. apt or apt-get. Use the following command to install Django on ubuntu,

$ sudo apt-get install python3-django

This will install Django compatible with python 3. But if you need to install Django for python 2, which we don’t recommend since python 2 is no longer supported, you can use the following command,

$ sudo apt-get install python-django


2- Install Django using PIP

We have already discussed how to install PIP on the Ubuntu system, please refer to the article if you need to install PIP. You can also use the following command to install PIP,

$ sudo apt-get install python3-pip

So now to install Django using pip, the command is,

$ pip3 install django

We will now have a stable version of Django installed on our system.


3- Install Django using the Github Packages

Any of the two above methods should work for you for installing a stable version of Django but if for some reason you need to use the development version of Django, you need to use the package files available on the Github repository. So before we process with this method, we must have GIT & PIP both installed onto our system. Install PIP & GIT with the following commands,

$ sudo apt-get install python3-pip

$ sudo apt-get install git

Now we can use git to clone the Django repository to our local system,

$ mkdir ~/django

$ cd ~/django

$ git init

$ git clone git://github.com/django/django

Now we need to install Django using the pip command,

$ pip install -e ~/django

This command will now install Django on Ubuntu systems. With this, we end our tutorial on how to install Django on Ubuntu, please do let us know if you have any questions, queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.