๐ Django Tutorial – Module 2
Topic: Django Project & App Structure
๐ฏ Learning Objectives
- Understand Django project vs app
- Create a Django app
- Explore Django folder structure
- Register app in settings
๐น What is a Django Project?
A Django project is the entire web application. It contains settings, URLs, and configuration.
๐น What is a Django App?
A Django app is a module that performs a specific function (e.g., blog, accounts, attendance).
๐น Step 1: Create Django App
python manage.py startapp blog
๐น Step 2: Project Structure
mysite/
│
├── blog/
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
│
├── mysite/
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│
└── manage.py
๐น Step 3: Register App in settings.py
INSTALLED_APPS = [
'blog',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
๐น Step 4: Run Server Again
python manage.py runserver
๐งช Student Practice
- Create another app named
pages - Add it to
INSTALLED_APPS - Observe the folder structure
❓ Viva / Exam Questions
- What is the difference between Django project and app?
- Why do we add apps to INSTALLED_APPS?
- What is the role of manage.py?
๐ Classroom Tip
Keep Module 1 & Module 2 HTML files open
Let students copy commands directly
Ask them to explain project structure verbally
No comments:
Post a Comment