Introduction
If you’re new to Django, one of the most confusing things at the beginning is its project structure.
After running django-admin startproject, you suddenly see files like:
settings.pyurls.pywsgi.pyasgi.py
And folders inside folders 😵💫
In this article, we’ll break down Django’s project structure in a simple, practical way, so you understand:
- What each file does
- Why Django is structured this way
- How this structure helps you build scalable applications
By the end, Django’s structure will feel logical, not scary.
Creating a Django Project (Quick Recap)
Let’s start fresh:
django-admin startproject myproject
cd myproject
Your folder structure will look like this:
myproject/
├── manage.py
└── myproject/
├── __init__.py
├── settings.py
├── urls.py
├── asgi.py
└── wsgi.py
Now let’s understand each part one by one.
1️⃣ manage.py – The Command Center
# manage.py
What it does:
- Helps you interact with your Django project
- Runs the development server
- Executes migrations
- Creates apps, superusers, and more
Common commands:
python manage.py runserver
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
👉 Think of manage.py as the remote control of your Django project.
2️⃣ The Inner Project Folder (myproject/)
This inner folder contains the core configuration of your project.
Important:
- The outer folder is just a container
- The inner folder is the actual Django project
3️⃣ settings.py – Project Configuration Brain 🧠
This is one of the most important files in Django.
What lives here:
- Installed apps
- Database configuration
- Middleware
- Templates
- Static & media files
- Security settings
Example:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'blog',
]
👉 Any time something “doesn’t work”, settings.py is usually involved.
4️⃣ urls.py – Traffic Controller 🚦
This file decides:
“Which URL goes to which view?”
Example:
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='home'),
]
Key idea:
- URLs map → Views
- Clean URL structure = better UX & SEO
👉 Think of urls.py as Google Maps for your website.
5️⃣ wsgi.py – Production Entry Point
WSGI stands for Web Server Gateway Interface.
Used when:
- Deploying Django to production
- Running with Gunicorn or uWSGI
You usually don’t touch this file, but it’s critical for deployment.
👉 Without wsgi.py, Django can’t talk to your server.
6️⃣ asgi.py – Async & Real-Time Support
ASGI is the modern version of WSGI.
Used for:
- WebSockets
- Real-time apps
- Django Channels
If you build:
- Chat apps
- Notifications
- Live dashboards
👉 asgi.py becomes very important.
7️⃣ init.py – Python Package Marker
This file tells Python:
“This folder is a package.”
Most of the time, you won’t modify it—but it’s required.
Apps vs Projects (Very Important Concept)
❓ Project
- Entire website
- Configuration & settings
❓ App
- A feature or module
- Reusable component
Example apps:
blogaccountsdashboardpayments
Create an app:
python manage.py startapp blog
App structure:
blog/
├── admin.py
├── apps.py
├── models.py
├── views.py
├── tests.py
└── migrations/
👉 One project = many apps
This is what makes Django clean and scalable.
Why Django Enforces This Structure
Django’s structure helps you:
- Separate concerns
- Avoid spaghetti code
- Scale teams and features
- Maintain large projects easily
This is why Django works well for:
- SaaS platforms
- Content sites
- Admin-heavy systems
- Enterprise applications
Common Beginner Mistakes ❌
❌ Putting everything in one app
❌ Editing settings.py randomly
❌ Not understanding URL routing
❌ Renaming core files
👉 Learn the structure once, and Django becomes much easier.
Best Practices ✅
✔ Keep apps small and focused
✔ Use meaningful app names
✔ Separate settings for dev & prod
✔ Organize templates by app
Final Thoughts
Django’s project structure may look complex at first, but it’s actually one of its biggest strengths.
Once you understand:
- Projects vs Apps
- URLs → Views → Templates
- Configuration flow
👉 Django becomes predictable, scalable, and enjoyable to work with.