How to install Django on Ubuntu 22.04
Introduction
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 22.04
Prerequisite
- Sudo access to your Ubuntu 22.04
Step 1 – Installing Python and Pip
If you have launched a new server. Then we recommend updating the server with the below command
apt-get update
By default, Python 3 is installed on your VPS, but if your system doesn’t have Python installed. Execute the below commands to install it
apt-get install python3
To install pip. Use below command
apt-get install python3-pip
Step 2: Installing Django
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

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
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.
nano django_app/settings.py
Add the IP
ALLOWED_HOSTS = ['your_server_IP']
Finally, run the Django application server with below command
python3 manage.py runserver 0.0.0.0:8000
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
Conclusion
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.