2 Easy Methods to Install Django on Ubuntu 22.04

There are many web applications which are made up of long and complicated codes. Due to these lengthy codes, it takes a long time for a web application to be launched, this issue is resolved by Django. Now, you can create your own web applications with simple and less code using Django, it will make your web applications more efficient.

What is Django?

Django is an open-source Python framework for the web, so anyone can access Django in web development and build web applications from the level of simple to complex applications quickly. Django is fully loaded with tools that are useful for the developers in web application development, such as user authentication and RSS feeds. Django is scalable, therefore, many famous websites are using it as it can handle heavy traffic easily as well as it provides the full security proof plans to manage user accounts and passwords.

In this guide, we are going to explore the installation methods of Django on the latest release of Ubuntu Jammy Jellyfish using the command-line interface.

How to install Django on Ubuntu 22.04

There are two methods to install Django on Ubuntu which are listed below:

  • Through the default repository of Ubuntu
  • Through the Git repositories

Both the methods are explained in detail in the next sections of this guide.

Method 1: Installing Django on Ubuntu through default repository of Ubuntu

This is the most convenient method to install any packages on Ubuntu, so we will first update all the available packages on Ubuntu repository by using the command:

$ sudo apt update

After updating, we will confirm the installed Python version using the command:

$ python3 -V

Then we will use the apt package manager to install the package of Django from default repository:

$ sudo apt install python3-django -y

To validate the installation, we will check the version of installed Django using the command:

$ django-admin --version

To remove this installed package of Django use the purge command:

$ sudo apt purge python3-django -y

Method 2: Installing Django on Ubuntu through Git repository

The other method to install Django is downloading it from Git repository, for this, we have to install the pip and python management packages by using the command:

$ sudo apt install python3-pip python3-venv -y

Now we will clone the directory of Django from the git repository to our home directory using the command:

$ git clone https://github.com/django/django.git ~/django-dev

Navigate to the cloned directory using the cd command:

$ cd ~/django-dev

Before the installation of Django, we will create the virtual environment “LinuxHint_env” for the Django and also activate the virtual environment “LinuxHint_env” using the command:

$ python3 -m venv LinuxHint_env && source LinuxHint_env/bin/activate

Now with the help of pip, we can install Django:

$ pip install -e ~/django-dev

Check the version of installed Django using the command:

$ django-admin --version

Conclusion

Django is a framework for the web developers to build web applications with the code of a few lines so the launch time of the application can be reduced. In this guide, we have explored two different methods of installing Django on Ubuntu, one is from its own repository, and the other is from the git repository.



from https://ift.tt/u9ZsPNd

Post a Comment

0 Comments