One of the most defining characteristics of Django is its clean modularity. Unlike monolithic frameworks where all routes, database schemas, and views are lumped into a single folder, Django separates concerns into Projects and Applications.
Think of a Django Project as an entire e-commerce store (e.g. Amazon or Flipkart). The project configures database connections, global security keys, and root routing. Within that store, individual Apps handle dedicated business domains:
To create a new project called mywebsite, execute the following command:
# Create the project scaffold
django-admin startproject mywebsite .
# (Notice the trailing dot '.' - it creates the project files in the current folder
# rather than creating an extra nested directory level!)
This command creates the following directory structure:
mywebsite/
├── manage.py # CLI utility for server, migrations, shell
└── mywebsite/ # Project configuration package
├── __init__.py # Marks this folder as a Python package
├── settings.py # Global configuration, database, middleware
├── urls.py # Root URL routing table
├── asgi.py # Entry point for ASGI async servers
└── wsgi.py # Entry point for WSGI synchronous web servers
To create an app called blog, use manage.py startapp:
# Create the blog application
python manage.py startapp blog
This generates a modular package with dedicated files for every MVT layer:
blog/
├── __init__.py
├── admin.py # Admin dashboard registrations
├── apps.py # AppConfig metadata
├── models.py # Database models (M in MVT)
├── tests.py # Automated unit and integration tests
├── views.py # HTTP request handlers (V in MVT)
└── migrations/ # Auto-generated database migration scripts
└── __init__.py
Open mywebsite/settings.py and add your new app to the INSTALLED_APPS list:
# mywebsite/settings.py
INSTALLED_APPS = [
# Built-in Django batteries
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Your custom applications
'blog.apps.BlogConfig', # Or simply 'blog'
]
Common Exam Question: "Explain the difference between startproject and startapp in Django."
Model Answer: startproject initializes the outer project configuration container (settings.py, urls.py, wsgi.py, and manage.py). startapp creates a pluggable, reusable functional unit containing models.py, views.py, admin.py, and migrations.
Broaden your backend architecture, REST API design, and production engineering expertise:
Register INSTALLED_APPS, middleware, and database engines.
Organize modular urls.py files per app with namespace resolution.
Define business logic data tables inside models.py for each app.
Reinforce project structure and app design with practical coding labs.