How to Install Django on Ubuntu 18.04

Install Django on Ubuntu 16.04

In this tutorial we are going to learn how to install Django on Ubuntu 18.04. We will also install and configure its prerequisites. Django is a popular Web framework for writing web applications. With Django you can build faster and scalable applications, without writing the code from scratch (without reinventing the wheel). Web framework was designed to aid programmes to create applications. These web frameworks are the core and takes care of functionalities like user session management, database connectivity etc.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Django on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing pip and necessary dependencies.

Use the commands below to install the latest version of python pip:

apt-get install python3-pip

Check if pip is successfully installed:

# pip3 -V
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

Step 3. Installing Djanggo on Ubuntu 18.04.

Install Django globally using the following command:

pip3 install django

To verify the Django version, run:

django-admin --version

Step 5. Create your first Django project.

Now that the Django framework has been installed, you can to give it a test drive by creating a sample project:

cd ~
django-admin startproject chedelics

The command will generate new Django application called chedelics which you can use for your next project. For more information about how to get started with Django it is recommended to refer to the official Django documentation.

Run the commands below in sequence to get your application started:

cd chedelics/
python3 migrate
python3 createsuperuser
python3 runserver

Step 6. Accessing Django Web Installation.

Now you can access the Django web install wizard in your browser by entering the domain name port 8000 or http://your_ip/8000 to continue your Django installation.

Install Django on Ubuntu 18.04

You can also access the Django admin page by typing the URL server_IP_addr:8080/admin on your web browser:

Install Django on Ubuntu 16.04

Congratulation’s! You have successfully¬†install and configured Django on your Ubuntu 18.04 LTS Bionic Beaver¬† server. Thanks for using this tutorial for installing Django on Ubuntu 18.04 system.