Lesson 1: Introduction to Django
Lesson 1 – Introduction to Django & How It Works
🎯 Lesson Objectives
By the end of this lesson, you will understand:
- What Django is and why it’s used by professional developers
- The MVT (Model–View–Template) architecture
- How Django handles requests internally
- The core parts of a Django project
- What you will build in this course
This lesson is designed for beginners, but it also connects to real workplace scenarios—such as maintaining, modifying, or extending existing Django applications used within your company.
🧩 1. What is Django?
Django is a high-level Python web framework for building modern, secure, and scalable web applications.
It is designed to help developers:
- Build applications faster
- Reduce repetitive tasks
- Maintain clean, organized code
- Work with databases easily
- Use templates for powerful front-end pages
Django is used by companies like:
- Mozilla
- Shopify
- Dropbox
- National Geographic
And many internal company systems worldwide.
🏗️ 2. Django’s MVT Architecture
Django uses an architecture called MVT — Model, View, Template.
Think of it as three layers working together:
🔹 Model
- Represents the data (database structure)
- Example: a table of employees, products, articles, etc.
- Written in Python
- Django automatically builds the database for you via migrations
🔹 View
- Python functions/classes that handle the logic
- Example: “Get all articles and show them to the user”
- Views prepare the data and send it to the template
🔹 Template
- The HTML page the user sees
- Can contain variables, loops, conditions
- Example: a page listing all products from the database
🔁 How they work together
Browser Request → URL → View → Model (optional) → Template → Browser Response
This flow is the core of Django development. Once you understand this, you can read or build any Django project.
🗂️ 3. The Django Project Structure
When you create a Django project, you’ll see this structure:
project_name/
manage.py
project_name/
settings.py
urls.py
wsgi.py
app_name/
models.py
views.py
urls.py
templates/
static/
What you will mostly work with:
| File / Folder | Purpose |
|---|---|
| models.py | Database structure |
| views.py | Page logic |
| templates/ | HTML pages |
| urls.py | Page routing |
This separation keeps projects clean and scalable — which is why companies choose Django for serious web development.
🧠 4. Example Real-World Scenario
Let’s imagine your company has an internal Django dashboard for managing customers, products, or inventory.
A user visits:
/products/
Here is what happens:
- URL: The request matches a URL pattern in
urls.py. - View: Django calls the view that handles products.
- Model: That view fetches product data from the database.
- Template: The view sends the data into an HTML template.
- Response: The browser displays a product list.
As you learn Django, you will be able to update pages, add fields, create new features, fix bugs, and extend the system without breaking anything.
🏋️ 5. Course Direction
During this course you will learn to:
- Build Django projects from scratch
- Understand and modify existing projects inside your company
- Work with templates, models, and views confidently
- Create APIs with Django REST Framework
- Deploy your projects on a real Ubuntu server
- Use GitHub for professional version control
- Build a final portfolio project
Everything will be project-based and hands-on.
✏️ 6. Lesson 1 Quick Exercise
Answer these three questions (mentally or in your notebook):
- What is a Model?
- What is a View?
- What is a Template?
If you can explain each in one sentence, you are ready for Lesson 2.
Answers
🚀 Next Step
Say “Start Lesson 2” whenever you’re ready, and I will guide you through:
- Installing Django on your Ubuntu server
- Creating your first project
- Running it in the browser