Before authoring any Django application, establishing a clean, reproducible, and isolated local development environment is critical. This guide walks you through verifying your Python runtime, creating isolated virtual environments, and installing the latest LTS release of Django.
Django 5.x requires Python 3.10, 3.11, or 3.12+. Open your terminal (PowerShell on Windows, Terminal on macOS/Linux) and execute:
# Check Python runtime version
python --version
# Output should be: Python 3.10.x, 3.11.x, or 3.12.x
# Check pip package manager version
python -m pip --version
If Windows reports 'python' is not recognized as an internal or external command, re-run the Python installer from python.org and check the box that says "Add python.exe to PATH".
Navigate to your project folder and initialize an isolated virtual environment using Python's standard venv module:
# Navigate to your workspace directory
cd G:\Programming\django_workspace
# Create a virtual environment named 'venv'
python -m venv venv
# Activation on Windows PowerShell:
venv\Scripts\Activate.ps1
# Activation on Windows Command Prompt (CMD):
venv\Scripts\activate.bat
# Activation on macOS / Linux:
source venv/bin/activate
Once activated, your terminal prompt will display (venv) at the beginning of the command line, confirming that all subsequent pip install commands will be contained safely within this directory.
With the virtual environment active, ensure pip is updated and install Django:
# Upgrade pip to latest release
python -m pip install --upgrade pip
# Install the latest stable Django release
pip install django
# Verify the installation and version
python -m django --version
# Output example: 5.1.x
In professional engineering and university lab submissions, always export your installed packages so team members and grading examiners can replicate your environment with a single command:
# Export installed dependencies
pip freeze > requirements.txt
# To install dependencies on another machine:
pip install -r requirements.txt
Open a Python interactive shell by typing python in your activated terminal. Type import django; print(django.get_version()). If it prints your version without an ImportError, your environment is ready to build projects!
Broaden your backend architecture, REST API design, and production engineering expertise:
Create your first project and understand the purpose of each generated file.
Manage configuration securely using django-environ and decouple secrets.
Construct relational database tables using Python class declarations.
Quick-fire academic exam questions on Django installation, CLI, and setup.