Easy to Install Django on Ubuntu 20.04

In this tutorial, we shall show you how it is easy to install Django on Ubuntu 20.04. We shall install Django with pip in a virtual environment. This is typically the most practical and recommended approach to working with Django.

Django is a Python-based free and open-source web framework that follows the model-template-views architectural pattern. Django is a full-featured Python web framework for developing dynamic websites.


Install Django on Ubuntu 20.04

Step 1 – Keep the server up to date

# apt update -y

# apt upgrade -y

Check the version of Python you have installed.

# python3 -V

Next, let’s install pip and venv from the Ubuntu repositories:

# apt install python3-pip python3-venv -y

Create a virtual environment to start a new project.

First, create a new project directory:

# mkdir ~/newproject
# cd ~/newproject

Now, create a virtual environment with a project directory using the python command.

# python3 -m venv my_env

This will install standalone versions of Python and pip into an isolated directory structure within your project directory.

To install packages into the isolated environment, you must activate it by typing:

# source my_env/bin/activate

If you look carefully, the prompt will look like:


Now, let’s install Django using pip command.

(my_env)# pip install django

You can verify the installation by typing:

(my_env)# django-admin –version



If you want to leave the virtual environment, using the deactivate command:

(my_env)# deactivate

The installation is completed successfully.

In this tutorial, we have shown you how it is easy to install Django on Ubuntu 20.04.


Related Articles