1. Home
  2. How to Install Django on Ubuntu 18.04 & 16.04 LTS

How to Install Django on Ubuntu 18.04 & 16.04 LTS


Django is a Python-based free and open-source web framework, which follows the model-template-view architectural pattern. It is maintained by the Django Software Foundation, an independent organization established as a 501 non-profit. Django’s primary goal is to ease the creation of complex, database-driven websites.In this article we will show you the steps to Install Django on Ubuntu 18.04 & 16.04 LTS


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

Step 1 – Installing Python and Pip

If you have launched a new server,Then we recommend to update the server with below command

sudo apt-get update

By default, Python 3 is installed on your, but if your system doesn’t have Python installed, Execute the below commands to install it

sudo apt-get install python3 

To check the version

$ python3 -V
Python 3.6.8

To install pip,Use below command

sudo apt-get install python3-pip

To check the version

pip3 -V

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

Step 2 : Installing Django

Django source code is available as Github repository. You can also use pip to install Django on Ubuntu systems

pip3 install Django

After Django is installed,You can verify the version

django-admin –version


Step 3 : Create A Django Application

The django-admin command provides you the option to create a new Django application via command line.Navigate to the directory you need to create a new application and use below command

django-admin startproject django_app

Go to the path and migrate the changes

cd django_app
python3 manage.py migrate

Step 4 : Creating a Super User for Django Application

We will now be creating a superuser account for the administration of the Django application. Run the following command from your Django application directory.

python3 manage.py createsuperuser

You will get an output as below,Enter the details

Step 5 : Run the Django Application

Your Django application is ready to use. By default, Django doesn’t allow external hosts to access the web interface. To allow external hosts, edit settings.py file and add IP under ALLOWED_HOSTS.

vim django_app/settings.py

Add the IP

ALLOWED_HOSTS = ['your_server_IP']

Note : Change your_server_IP details with your actual server IP as xx.xx.xx.xx

Finally, run the Django application server with below command

python3 manage.py runserver

Django application server is running now. Open your web browser and access the Django Application with your server IP on port 8000. This will show you the default Django web page.

Before accessing the Django application on browser,You need to open the port on the server to access it externally,Refer this article to open the port on Iptables

To use administrative interface,Access with /admin

Login with username and password which was provided earlier by you on previous step


You have now installed Django application on your server, After accessing and login to browser you can add more users and groups for your application and proceed with your setup.

Updated on November 9, 2019

Was this article helpful?

Add A Comment