Installing Django is a straightforward process. Here’s a step-by-step guide to get Django up and running on your system:
Step 1: Install Python
1. Ensure Python is installed on your system. Django requires Python 3.8 or higher.
2. Check if Python is already installed
python --version
or
python3 --version
3. If Python isn’t installed, download it from the official Python website and follow the installation instructions.
Step 2: Set Up a Virtual Environment (Recommended)
A virtual environment isolates your project’s dependencies, avoiding conflicts with other projects.
1. Install the venv
module if it’s not already installed:
python -m ensurepip --upgrade
2. Create a virtual environment:
python -m venv mydata
Replace mydata with your preferred name for the environment.
3. Activate the virtual environment:
On Windows:
mydata\Scripts\activate
On Mac/Linux:
source mydata/bin/activate
4. Your terminal prompt should change to indicate the virtual environment is active.
Step 3: Install Django
With your virtual environment activated, use pip
to install Django.
1. Install the latest version of Django:
pip install django
2. Verify the installation: This will display the installed version of Django.
python -m django --version