Presented By
2025
Django
Arindam Saha
Page 2
What is Django?
• Django is a high-level Python web framework
• Used to build websites and web applications
• Simplifies web development using Python
• Handles complex tasks automatically
• Allows developers to focus on application logic
Page 3
Why Use Django?
• Saves development time
• Follows DRY principle (Don’t Repeat Yourself)
• Built-in features:
oUser authentication
oDatabase connectivity
oCRUD operations
• Secure and scalable
• Widely used in industry
Page 4
How Does Django Work?
• Django follows the MVT Architecture
• MVT stands for:
oModel
oView
oTemplate
• Separates data, logic, and presentation
• Improves code organization and maintenance
Page 5
Django MVT Architecture
• Model → Handles database and data logic
• View → Handles user requests and responses
• Template → Handles user interface (UI)
• Django internally manages the flow between them
Page 6
Model (M)
• Represents data layer
• Interacts with the database
• Uses ORM (Object Relational Mapping)
• Eliminates need to write complex SQL
• Models are defined in models.py
Page 7
Django ORM
• ORM maps database tables to Python objects
• Enables database operations using Python code
• Supports:
oInsert
oUpdate
oDelete
oRetrieve data
• Makes database handling easy and secure
Page 8
View (V)
•Handles HTTP requests
•Processes business logic
•Fetches data from models
•Sends data to templates
•Views are defined in views.py
Page 9
Template (T)
•Defines how data is displayed
•Usually written in HTML
•Uses Django Template Language (DTL)
•Supports variables and logic
•Stored inside templates folder
Page 10
Template Example
<h1>My Homepage</h1>
<p>My name is {{ firstname }}.</p>
• {{ firstname }} is a template variable
• Data comes from the view
• Logic and UI are separated
Page 11
URLs in Django
•Manages navigation between pages
•Maps URL patterns to views
•Each request is routed to a view
•URL configuration stored in urls.py
•Enables clean and readable URLs
Page 12
Django Project Structure
• models.py Database models
→
• views.py Request handling logic
→
• templates/ HTML templates
→
• urls.py URL routing
→
• settings.py Project configuration
→
Page 13
History of Django
•Developed by Lawrence Journal-World
•Created in 2003
•Designed for fast web development
•Released publicly in July 2005
•Built to meet tight deadlines
Page 14
Django Versions
• Open-source framework
• Regular updates and improvements
• Latest version:
oDjango 4.0.3
oReleased in March 2022
• Supports modern web standards
Page 15
Key Advantages of Django
•Rapid development
•High security
•Built-in admin panel
•Scalable and flexible
•Strong community support
Page 16
Django Requirements – Overview
•Django is a Python-based web framework
•To work with Django, we need:
oPython
oPIP (Python Package Manager)
oVirtual Environment
Page 17
Django Requires Python
•Django is written in Python
•Python must be installed before installing Django
•Django supports Python 3.x versions
Page 18
Check Python Installation
•Open Command Prompt
•Run the command:
python --version
• If Python is installed, version will be displayed
• Example:
Python 3.13.2
Page 19
What is PIP?
•PIP = Python Package Installer
•Used to install Python libraries and frameworks
•Required to install Django
•Included with Python from version 3.4 onwards
Page 20
Check PIP Installation
•Open Command Prompt
•Run the command:
opip --version
•pip –version
•If installed, version details will appear
•Example:
opip 24.3.1 (python 3.13)
Page 21
Installing PIP (If Not Available)
• If PIP is not installed:
• Download it from:
https://pypi.org/project/pip/
• Follow installation instructions provided on the website
Page 22
What is a Virtual Environment?
• A Virtual Environment is an isolated workspace
• Keeps project dependencies separate
• Prevents version conflicts between projects
• Recommended for every Django project
Page 23
Why Use Virtual Environment in Django?
•Separate environment for each project
•Easy dependency management
•Cleaner and safer development
•Avoids system-wide package conflicts
Page 24
Next Steps
•Create a virtual environment
•Activate the virtual environment
•Install Django inside the virtual environment
•Start building Django applications
Page 25
Virtual Environment in Django
• A Virtual Environment is an isolated workspace for a Python
project
• It keeps project dependencies separate
• Recommended to use one virtual environment per Django
project
• Helps avoid version conflicts
• Python provides built-in support using venv
Page 26
Why Use Virtual Environment?
• Keeps project libraries isolated
• Avoids dependency conflicts
• Easy project management
• Safe environment for testing
• Required for professional Django development
Page 27
Creating a Virtual Environment
• Python includes venv module
• Choose any name for the environment
• Example name used: myworld
• Command to create virtual environment:
python -m venv myworld
• Run this command in Command Prompt / Terminal
• Navigate to project folder before running
Page 28
Virtual Environment Folder Structure
After creation, a folder named myworld is created with:
• Include – Header files
• Lib – Installed Python packages
• Scripts – Activation files (Windows)
• pyvenv.cfg – Configuration file
• .gitignore – Git ignore settings
Page 29
Activating Virtual Environment (Windows)
Activating Virtual Environment (Windows)
myworldScriptsactivate.bat
• Run inside project directory
• Activates the virtual environment
Page 30
Activating Virtual Environment (Linux / macOS)
To activate on Windows:
myworldactivate.bat
• Run inside project directory
• Activates the virtual environment
Page 31
Virtual Environment Activated
Once activated, command prompt changes to:
Windows:
(myworld) C:UsersYourName>
Linux / macOS:
(myworld) $
• (myworld) indicates active environment
• All Python packages will install inside this environment
Page 32
Check Python Installation
• Open Command Prompt / Terminal
• Run the command:
python --version
• If Python is installed, version is displayed
Example:
Python 3.13.2
Page 33
What is PIP?
• PIP = Python Package Installer
• Used to install Python libraries and frameworks
• Comes bundled with Python version 3.4 and above
• Required to install Django
Page 34
Check PIP Installation
• Open Command Prompt / Terminal
• Run the command:
pip –version
• Example output:
pip 24.3.1 from ... (python 3.13)
Page 35
QUESTIONS?
Page 36