Installation of Django Framework on Ubuntu 20.04

Installation of Django Framework on Ubuntu 20.04
Techiio-author
Written by Shuvhojit DebDecember 20, 2021
6 min read
Django
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Techiio-author
Shuvhojit Deb

Full Stack Developer

Today we'll know the process of installing Django Framework.

Install Django Framework

There are 4 different to install the Python Django Framework, install using the Apt repository, using pip command, using the virtualenv, or using the Django git version.

Install Django with Apt

By default, the Ubuntu 20.04 repository provides packages for Django Framework named 'python3-django'. At this time (tutorial writing), the Ubuntu repository provides Django 2.2.12, which is not the latest stable version of Django.

Check the 'python3-django' package using the apt command below.

apt show python3-django

And you will get details about the 'python3-django' package.

To install the package, run the apt command below.

apt install python3-django

Once all installation is completed, check the Django version using the following.

django-admin --version

You will get the following result.

blogpost

As a result, Django 2.12 is installed on ubuntu 20.04 through the official Ubuntu repository.

Install Django with PIP

The main advantage of installing the Django Framework with the pip command through the PyPI repository is that you can choose the right version of Django for your project.

For this section, we will install the Django 3.0 (latest stable version) from the PyPi repository.

Install Django framework 3.0 using the pip command below.

pip install django==3.0.0

Once all installation is completed, check the Django version using the following command.

django-admin --version

And you will get the Django version 3.0 as the response.

optionally, you can check through the Python interactive shell, run the python command below.

python

Import the Django module and show the Django version using the following query.

import django
print(django.get_version())

You will get the Django 3.0 response as below.

blogpost

As a result, you've successfully installed the Django 3.0 using the PyPi repository.

Install Django with Virtualenv

This is the most recommended practice for installing Django Framework, by using the python Virtualenv. It's a python environment builder that can be used to create isolated python environments.

You can choose the Python version that will be installed in the virtual environment, and all installation in the Python virtual environment will not affect the system. This is very useful for developers, they can run and develop an application with different python versions and different environments on one OS.

First, install the Python virtualenv packages from the PyPi repository using the pip command below.

pip install virtualenv

Once all installation is completed, create a new Python virtual environment 'myenv' using the following command.

virtualenv myenv

Now go to the 'myenv' directory and activate the virtual environment using the command as below.

cd myenv/
source bin/activate

After that, install the Python Django Framework using the pip command below.

pip install django==3.0.0

And the Python Django Framework is now installed on the Python virtual environment. Check the Django version using the following command.

django-admin --version

You will get the Django 3.0 as the response, and the Django Framework is installed on the Python virtual environment.

To back to the normal user and deactivate the virtual environment, run the command.

deactivate

Now you will be switched back to the normal user environment of your system.

blogpost

Install Django from Git Repository

This method is recommended if you want to install the development version of Django Framework.

First, install the git packages using the apt command below.

apt install git

Next, create a new virtual environment named 'django-git' using the virtualenv command below.

virtualenv django-git

Go to the 'django-git' directory and activate the virtual environment.

cd django-git/
source bin/activate

Clone the latest Django version from the official Django GitHub repository and install the Django development version using the pip command as below.

git clone git://github.com/django/django django-dev
pip install -e django-dev

Once all installation is completed, check the Django version.

django-admin --version

And you will get the latest version of the Django Framework development version.

Install Python Django from Source

blogpost

Now you've learned how to install Python Django using multiple ways.

Django
Django Install
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-author
Shuvhojit Deb
Full Stack Developer
Techiio-followerTechiio-follower
117 Blog Posts
0 Discussion Threads
Trending Technologies
15
Software40
DevOps46
Frontend Development24
Backend Development20
Server Administration17
Linux Administration26
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance