How Django Project Structure Works (Explained Simply)

Shriful-Islam
Shriful Islam
Published on Jan, 02 2026 3 min read 0 comments
image

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.py
  • urls.py
  • wsgi.py
  • asgi.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:

  • blog
  • accounts
  • dashboard
  • payments

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.

0 Comments