Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. This guide will provide a step-by-step tutorial on how to install Django on Ubuntu 22.04.
Before proceeding, make sure you have administrative access and your system is updated by running:
sudo apt update sudo apt upgrade
Step 1: Install Python
Django is a Python-based framework, so the first step is to make sure Python is installed. Ubuntu 22.04 comes preinstalled with Python 3.10, but you can confirm this by typing:
If for any reason Python is not installed, you can install it using:
udo apt install python3
Step 2: Install pip
Pip is a package manager for Python and it’s necessary to install Django. To install pip, run:
sudo apt install python3-pip
After the installation, verify it by typing:
Step 3: Install Django
Now we are ready to install Django. You can install Django using pip. To install the latest version, run:
pip3 install django
After the installation, you can check the Django version by typing:
python3 -m django --version
Step 4: Create a New Django Project
Now that Django is installed, you can create a new project. Navigate to the directory where you want to create your project and run:
jango-admin startproject myproject
Replace “myproject” with the name you want to give to your project.
Step 5: Test Django Installation
Finally, navigate to the project directory and start the development server to confirm everything is set up correctly:
cd myproject python3 manage.py runserver
You should see a message that the development server is running. Open your browser and go to
http://127.0.0.1:8000/. If Django is installed correctly, you should see a congratulatory message.
Congratulations! You’ve successfully installed Django on Ubuntu 22.04 and created your first Django project. Now you’re ready to start developing your web application. Remember, Django is a powerful tool, but with great power comes great responsibility. Happy coding!
Please note: The Django development server is only for development purposes. Do not use it to serve your application in a production setting.