How to Install Django on Ubuntu 18.04 and 16.04 LTS


Django is a high-level web framework that encourages rapid and development and clean. It gives higher security to the application and stays away from developers from committing regular security errors.

In this guide, we will be learning how to install and setup the Django project on your ubuntu server / Linux. Django is an open-source web project which follows the template-view-controller architecture pattern. 


Sudo access to your Ubuntu 18.04 (or) Ubuntu 16.04 server

Step 1. Installing Python and PIP

By default, Most of the system comes with the installed python3. If your system does not have python3 installed. Execute the following command to install it with pip.

sudo apt-get install python3 python3-pip

Once you are done with the installation. Execute the below command to check the installed python version.

python3 -V

Python 3.6.9

and to check the PIP version. Execute the below command

pip3 -V

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Step 2. Install Django framework/application

To install Django with pip3. Enter the below command.

pip3 install Django

Once you execute this command, you will now be able to access the Django-admin command to create a new project.

Note: To check the Django-admin version. Enter the below command

django-admin --version


Step 3. Create a Django Application

Django-admin gives you the option to install a new project via the command line. To install, navigate to the installation directory. eg: /var/www/html

and then run the django-admin startproject django-app 

cd /var/www/html
django-admin startproject django-project

Once it is installed, navigate to the project and run the following command to migrate

cd django-project
python3 migrate

After running the above command you will get something like below response in the terminal

Django migration

Step 4. Creating a superuser for Django application

Django entirely automates the creation of admin interfaces for models. To create admin users, execute the following command in your terminal.

python createsuperuser

django admin user

Step 5. Run the Django Application

 Your Django project is all set up. Now to test the Django application we need to run the server. To do so, enter the following command.

python3 runserver

Once you run the above command you will get the following responseDjango start server

The above response means your server is up and running. Now open your favorite browser and type the following address

This will show Django default homepage.

Django test url

By default, Django ships with an administrative web interface. You can access the admin dashboard at /admin URL. Copy and paste the below URL to test the admin dashboard.

Django admin login

Now enter your username and password which you created superuser earlier. The admin dashboard looks like below image

Django admin dashboard