MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Django Project Structure0%
Study Materials
Django for Backend DevelopmentProgress 0%
1.1Installing Django & Environment Setup1.2Django Project Structure1.3Creating First Django App
HomeTutorialsDjango for Backend DevelopmentDjango Project Structure
Creating First Django App

Django Project Structure

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

A well-structured Django project scales cleanly from a simple prototype into an enterprise platform with dozens of engineers. Understanding the distinction between a Project and an App, as well as the responsibilities of each generated file (settings.py, urls.py, wsgi.py, asgi.py), is foundational to backend engineering.


1. Projects vs Apps: The Architectural Distinction

  • Django Project: The overarching container and configuration root. It defines database connections, middleware pipelines, installed apps, global URL routing, and security settings. A project can contain multiple apps.
  • Django App: A focused, self-contained Python package that accomplishes a single business domain (e.g. users, billing, inventory, notifications). An app can theoretically be reused across different Django projects.
1my_enterprise_project/
2├── manage.py # Project management CLI
3├── config/ # Project Configuration Package
4│ ├── __init__.py
5│ ├── settings.py # Global project settings & configs
6│ ├── urls.py # Root URL dispatcher
7│ ├── asgi.py # ASGI entrypoint for WebSockets/async
8│ └── wsgi.py # WSGI entrypoint for synchronous servers
9└── apps/ # Custom Domain Apps
10 ├── accounts/ # User authentication & profiles
11 ├── billing/ # Stripe/PayPal transactions & invoices
12 └── products/ # Inventory & catalog models

2. Anatomy of settings.py

The settings.py file dictates all runtime behavior:

1import os
2from pathlib import Path
3 
4# Base project directory
5BASE_DIR = Path(__file__).resolve().parent.parent
6 
7# Security: Never keep SECRET_KEY or DEBUG=True in production!
8SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "dev-secret-key-change-me")
9DEBUG = os.environ.get("DJANGO_DEBUG", "True") == "True"
10ALLOWED_HOSTS = ["localhost", "127.0.0.1", ".enterprise.com"]
11 
12# Applications installed in this project
13INSTALLED_APPS = [
14 # Core Django apps
15 "django.contrib.admin",
16 "django.contrib.auth",
17 "django.contrib.contenttypes",
18 "django.contrib.sessions",
19 "django.contrib.messages",
20 "django.contrib.staticfiles",
21 # Third-party packages
22 "rest_framework",
23 "corsheaders",
24 # Local domain apps
25 "apps.accounts",
26 "apps.billing",
27]
28 
29# Middleware execution pipeline (order matters!)
30MIDDLEWARE = [
31 "django.middleware.security.SecurityMiddleware",
32 "django.contrib.sessions.middleware.SessionMiddleware",
33 "corsheaders.middleware.CorsMiddleware",
34 "django.middleware.common.CommonMiddleware",
35 "django.middleware.csrf.CsrfViewMiddleware",
36 "django.contrib.auth.middleware.AuthenticationMiddleware",
37 "django.contrib.messages.middleware.MessageMiddleware",
38]
39 
40# Database configuration (PostgreSQL in production, SQLite in local dev)
41DATABASES = {
42 "default": {
43 "ENGINE": "django.db.backends.sqlite3",
44 "NAME": BASE_DIR / "db.sqlite3",
45 }
46}

3. WSGI vs ASGI Entrypoints

  • wsgi.py (Web Server Gateway Interface): The synchronous Python web standard. Used by traditional production WSGI servers like Gunicorn or uWSGI to serve synchronous HTTP views.
  • asgi.py (Asynchronous Server Gateway Interface): The modern asynchronous Python specification. Required for handling asynchronous views, WebSockets (via Django Channels), and long-lived streaming connections with servers like Uvicorn or Daphne.

4. Root URL Routing (urls.py)

The root urls.py delegates subpaths to specific apps via include():

1from django.contrib import admin
2from django.urls import path, include
3 
4urlpatterns = [
5 path("admin/", admin.site.urls),
6 path("api/v1/auth/", include("apps.accounts.urls")),
7 path("api/v1/billing/", include("apps.billing.urls")),
8]

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What is the fundamental difference between a Django Project and a Django App?
Question 2
What is the purpose of asgi.py compared to wsgi.py?
Question 3
Why is DEBUG = False mandatory in production environments?
Question 4
What does the include() function do in the root urls.py?
Question 5
Why is the order of items in the MIDDLEWARE list important?
Next Lesson

Creating First Django App

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Installing Django & Environment SetupCreating First Django App

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Django for Backend Development with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext