Skip to main content
Course/Module 2/Topic 1 of 5Beginner

Django Installation & Setup

Learn how to install Django, set up a virtual environment, and create a new Django project.

45 minBy Priygop TeamLast updated: Feb 2026

What is Django?

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It follows the Model-View-Template (MVT) pattern and includes many built-in features.

Installation

Example
# Install Django using pip
pip install django

# Check Django version
python -m django --version

# Create a virtual environment (recommended)
python -m venv myenv

# Activate virtual environment
# On Windows:
myenv\Scripts\activate

# On macOS/Linux:
source myenv/bin/activate

# Install Django in virtual environment
pip install django

# Create a new Django project
django-admin startproject myproject

# Navigate to project directory
cd myproject

# Run the development server
python manage.py runserver

# Access your site at http://127.0.0.1:8000/

Practice Exercise: Project Setup Script

Example
# Django Project Setup Script
import os
import subprocess
import sys

def create_django_project():
    """Automated Django project setup"""
    project_name = input("Enter project name: ")
    
    # Create virtual environment
    print(f"Creating virtual environment for {project_name}...")
    subprocess.run([sys.executable, "-m", "venv", f"{project_name}_env"])
    
    # Activate virtual environment and install Django
    if os.name == 'nt':  # Windows
        activate_script = f"{project_name}_env\Scripts\activate"
        pip_path = f"{project_name}_env\Scripts\pip"
    else:  # macOS/Linux
        activate_script = f"{project_name}_env/bin/activate"
        pip_path = f"{project_name}_env/bin/pip"
    
    print("Installing Django...")
    subprocess.run([pip_path, "install", "django"])
    
    # Create Django project
    print(f"Creating Django project: {project_name}")
    subprocess.run([pip_path, "run", "django-admin", "startproject", project_name])
    
    print(f"\nProject {project_name} created successfully!")
    print(f"To get started:")
    print(f"1. cd {project_name}")
    print(f"2. Activate virtual environment: {activate_script}")
    print(f"3. Run: python manage.py runserver")

if __name__ == "__main__":
    create_django_project()

📚 Additional Resources

Recommended Reading

  • Django Official Documentation
  • Django for Beginners by William S. Vincent
  • Two Scoops of Django by Daniel Greenfeld

Online Resources

  • Django Tutorial (djangoproject.com)
  • Django Girls Tutorial
  • Real Python Django Tutorials
Chat on WhatsApp
Priygop - Leading Professional Development Platform | Expert Courses & Interview Prep