How to Create a Django Project in Linux/Ubuntu 22.04.4

May 13, 2025 (4d ago)

How to Create a Django Project in Linux/Ubuntu 22.04.4

Table of Contents

  1. Why Django on Ubuntu 22.04?
  2. Prerequisites
  3. Step 1: Update Your System
  4. Step 2: Install Python & pip
  5. Step 3: Create a Virtual Environment
  6. Step 4: Install Django
  7. Step 5: Start Your Django Project
  8. Step 6: Run the Development Server
  9. What’s Next?
  10. FAQ
  11. Conclusion

Why Django on Ubuntu 22.04?

Ubuntu 22.04 LTS is a rock-solid, long-term support release. Pairing it with Django—one of the most popular Python web frameworks—gives you stability, security, and productivity. Perfect for everything from prototypes to production apps.

Prerequisites

Before you begin, make sure you have:


Step 1: Update Your System

sudo apt update && sudo apt upgrade -y

Keeping your OS packages up-to-date ensures you get the latest security patches and library versions.

Step 2: Install Python & pip

Ubuntu 22.04 ships with Python 3.10, but let’s install pip and venv:

sudo apt install python3-pip python3-venv -y

Step 3: Create a Virtual Environment

Isolating your project dependencies avoids version conflicts:

cd ~
python3 -m venv my_django_env
source my_django_env/bin/activate

Step 4: Install Django

With your venv active, install the latest Django release:

pip install django

Verify the installation:

django-admin --version

Step 5: Start Your Django Project

Generate a new project scaffold:

django-admin startproject mysite
cd mysite

You’ll see:

mysite/
├── manage.py
└── mysite/
    ├── __init__.py
    ├── asgi.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

Step 6: Run the Development Server

Launch Django’s built-in server:

python manage.py runserver 0.0.0.0:8000

What’s Next?


FAQ

Q1: Can I use Python 3.11 instead?

Yes, you can install via deadsnakes PPA, but ensure compatibility with Django’s supported versions.

Q2: How do I upgrade Django later?

pip install --upgrade django

Q3: Where are my static files?

Collect them via python manage.py collectstatic and serve with Nginx in production.

Conclusion

You now have a fully functioning Django project running on Ubuntu 22.04.4. From here, you can build apps, integrate databases, and deploy to production. Happy coding!