27 C
Jaipur
Sunday, October 18, 2020

How to Install Django on Ubuntu 20.04 – Linux Hint

Must read

How Apple Developed ‘Ceramic Shield’ Glass for the iPhone 12

Apple, with the launch of the new iPhone 12 models, introduced a new protective layer for the OLED displays of the current and future...

Microsoft’s New Image Captioning AI Is as Accurate as Humans

Since researchers started working on artificial intelligence (AI), one of the primary goals has always been an advanced image captioning system. Many companies are...

Apple Working on an iPhone with a Slide-out Display

Over the past year or so, we have seen a shift in smartphone design and phone makers are now experimenting with foldable, swivel, or...

​Amazon Great Indian Festival sale: 12 phones from Apple, Xiaomi, Samsung and others available at ‘lowest-ever’ price

Amazon’s biggest annual festival sale is live. The 7-day sale has deals and discounts on a range of products -- fashion, grocery, electronics, household...

Django was developed and is currently maintained by the Django Software Foundation. It is a free Python-based web application framework that allows its users to accelerate the app development process by nullifying often encountered errors such as SQL Injection, CSRF, XXS, etc. IT incorporates the Model-View-Controller (MVC) architecture, which makes it a lightweight and robust programming utility.

It is used by app developers all over the world, including major tech firms. It was also used to create some of the most famous websites on the web. The most notable websites constructed on Django are Instagram, Disqus, Pinterest, Knight Foundation, and The Washington Post.

This is a walkthrough that’ll take a look at two different ways to install Django on an Ubuntu 20.04 system using an account with sudo privileges. These three methods are:

  • Installing Django from Ubuntu repositories
  • Obtaining Django from GIT and installing Django with pip

We will discuss the perks each installation method has in this article in appropriate sections. Let’s discuss the installation method involving Ubuntu repositories.

Method 1: Install from Ubuntu official repositories

The simplest and easiest method to install Django on an Ubuntu server is to just use Ubuntu’s official repositories with the apt package manager. Although the method is straightforward, you might miss out on some customizability options that other methods have to offer.

Step 1: Update the package list

First, update the package index for your server with the following command:

Step 2: Update the python version

See what version of Python is installed on your system with the following command:

That should print the current version of Python on your system.

Step 3: Install Django:

Now it’s time to install Django. Use the following command:

$ sudo apt install python3-django

Django should be installed on your system. Now you’re just short of verifying the install.

Step 4: Verify the install

Enter the following command:

It could be that the version that you just installed isn’t the latest one. This is a drawback of downloading from the standard repositories: they don’t always have the latest version available. But that’s quite rare, and you can always update the thing so not a major issue.

Method 2: Installing from Git repositories

Whereas the Ubuntu repositories have the latest stable version available, Git Repos lets you download the development version, which, while more volatile, boasts the latest features.

For this demonstration, Django will be downloaded from GIT by creating a virtual environment with venv.

Step 1: Refresh the package index

See the versions available for download with the following code:

Step 2: Check the python version installed on your system

See what version of Python is installed on your system with the following command:

That should print the current version of Python on your system.

Step 3: download python packages

You need to install pip, a package management system for python.

Also, if you don’t already have venv installed, you’re going to need that as well.

To download both of these, enter the following command:

$ sudo apt install python3-pip python3-venv

Next, clone the repository to the ~/django-dev directory with your home directory. Type in the following commands:

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

Step 4: Create a virtual environment with venv

Next, create a virtual environment to install Django on with the venv module. Type in the following command:

$ source my_env/bin/activate

A virtual environment has been activated on your system.

Step 5: Install Django

Next, you can install the repository using pip. Type in the following command:

$ pip install -e ~/django-dev

You can verify that the installation was successful by typing:

That’s it. Django has been installed with the latest version on your system.

In summary

In this brief tutorial, we discussed two different methods to get Django up and running on your system. The first method was the most straightforward; you just directly install it from the standard Ubuntu repositories. The second method used the Git repositories to install the development version instead of the latest stable version and then installed using pip and venv modules to install Django. This method is arguably the best as it gives you the most control over the specifications of the install.

I hope you’ve found this article useful. Check out the official page for Django to learn more.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How Apple Developed ‘Ceramic Shield’ Glass for the iPhone 12

Apple, with the launch of the new iPhone 12 models, introduced a new protective layer for the OLED displays of the current and future...

Microsoft’s New Image Captioning AI Is as Accurate as Humans

Since researchers started working on artificial intelligence (AI), one of the primary goals has always been an advanced image captioning system. Many companies are...

Apple Working on an iPhone with a Slide-out Display

Over the past year or so, we have seen a shift in smartphone design and phone makers are now experimenting with foldable, swivel, or...

​Amazon Great Indian Festival sale: 12 phones from Apple, Xiaomi, Samsung and others available at ‘lowest-ever’ price

Amazon’s biggest annual festival sale is live. The 7-day sale has deals and discounts on a range of products -- fashion, grocery, electronics, household...

Amazon Great Indian Festival sale: 6 fitness bands you can buy under Rs 5,000

Amazon Great Indian Festival sale: 6 fitness bands you can buy under Rs 5,000 Source link