Ubuntu Linux

How to Install Django 5 on Ubuntu 24.04

Richard
Written by
Richard
Mar 16, 2025 Updated Mar 20, 2026 4 min read
How to Install Django 5 on Ubuntu 24.04

This article describes installing Django 5, the Python web framework, on Ubuntu 24.04 using a Python virtual environment, which users can set up in their home directory.

Django is a Python web framework that lets you develop clean and pragmatic design. It allows users to follow the “Don’t Repeat Yourself” (DRY) principle, enabling focus on application development without unnecessary duplication of effort.

Installing Django in a Python virtual environment allows developers to maintain a clean workspace for their projects. This approach enables you to install packages without impacting the global Python installation on your system, ensuring that your project’s dependencies remain isolated from those of other projects.

Install Python

Django is a Python framework that requires Python to be installed. If you haven’t done so yet, use the command below to install Python.

🐧Bash / Shell
sudo apt update
sudo apt install python3.12 python3.12-venv

After installing, you can check the Python version using the command below.

💻Code
python3 -V

Install Django 5

Once Python is installed, anyone on the Ubuntu machine can install Django in a Python virtual environment.

Within your home directory, run the command below to create a Python environment and download Django 5 packages.

💻Code
python3 -m venv --system-site-packages ~/django5

Then, activate the environment.

💻Code
source ~/django5/bin/activate

Install Django 5.

💻Code
pip3 install 'Django>=5,<6'

You can check the Django version after installing using the command below.

💻Code
django-admin --version

When you finish with the virtual environment, run the command below to exit it.

💻Code
deactivate

Create your project

After installing Django, create your first project, follow the steps below.

Activate the Django 5 environment.

💻Code
source ~/django5/bin/activate

Create an app folder called myproject.

💻Code
django-admin startproject myproject

Change into the myproject folder.

Command Prompt
cd myproject

Configure a database. Default is SQLite.

💻Code
python manage.py migrate

Create an admin user.

💻Code
python manage.py createsuperuser

When prompted, enter a username, password, and email address.

💻Code
Username (leave blank to use 'richard'):      
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.

You can now start the project using the command below.

💻Code
python manage.py runserver 0.0.0.0:8000

Open your browser and browse to the localhost name, followed by port 8000 to see the Django default web portal.

💻Code
http://localhost:8000
Django web portal

To access the Django from another machine, edit the networking settings.

💻Code
vi myproject/settings.py

Then, add this line

💻Code
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']

Save and exit.

Within your project folder, you can start creating your apps.

That should do it!

Conclusion:

In summary, installing Django on Ubuntu 24.04 using a Python virtual environment is a straightforward process that provides a clean workspace for your projects. Here are the key takeaways:

  • Django Framework: Enables rapid development and follows the DRY principle for efficient coding.
  • Virtual Environment: Keeps your project’s dependencies isolated, avoiding conflicts with global Python installations.
  • Installation Steps: Installing Python and setting up Django in a virtual environment is simple and manageable.
  • Creating Your First App: You can quickly start developing your first app with the provided commands and configurations.
  • Accessing Your Project: Adjust network settings to access your Django application from other machines.

Following this guide, you can start developing with Django and leverage its powerful features for your web applications.

Frequently Asked Questions

How do I install Python on Ubuntu 24.04?

To install Python on Ubuntu 24.04, open your terminal and run the command 'sudo apt update' followed by 'sudo apt install python3.12 python3.12-venv'. This will install Python 3.12 along with the virtual environment package.

What is a Python virtual environment and why should I use it?

A Python virtual environment is an isolated workspace that allows you to manage dependencies for different projects separately. Using a virtual environment prevents conflicts between package versions and keeps your global Python installation clean.

How can I check the installed version of Django?

After installing Django, you can check the version by activating your virtual environment and running the command 'django-admin --version'. This will display the currently installed version of Django.

What are the steps to create a new Django project?

To create a new Django project, first activate your virtual environment, then run 'django-admin startproject myproject' in your terminal. This will create a new folder named 'myproject' containing the necessary files for your Django application.

”How

”To
' to permit access from any host.”]

Was this guide helpful?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

2460 articles → Twitter

📚 Related Tutorials

How to Install Apache Groovy on Ubuntu Linux
Ubuntu Linux How to Install Apache Groovy on Ubuntu Linux
How to Install ProjectSend with Nginx on Ubuntu Linux
Ubuntu Linux How to Install ProjectSend with Nginx on Ubuntu Linux
Disable Laptop Suspend When Lid Closes in Ubuntu
Ubuntu Linux Disable Laptop Suspend When Lid Closes in Ubuntu
How to Install OpenJDK 21 on Ubuntu 24.04
Ubuntu Linux How to Install OpenJDK 21 on Ubuntu 24.04

Leave a Reply

Your email address will not be published. Required fields are marked *