← Back to Django Course | Chapter 1: Django Fundamentals & Setup | Lesson 7 of 9

Django Project Structure

A Django project is organized into folders and files that each have one clear job, like rooms in a house each used for something different.

The Outer Project Folder

The top-level folder created by startproject holds manage.py and the inner settings package; everything for the whole project lives under this one folder.

Example: The Outer Project Folder

ls right after startproject shows the outer folder contains just manage.py and one inner folder — everything for the whole project lives under this one directory.

bash
django-admin startproject mysite
ls mysite/

⚠️ Run this in your own terminal or Node.js environment.

The Inner Settings Package

Inside the outer folder is another folder with the same project name, containing settings.py, urls.py, wsgi.py, and asgi.py — the actual configuration package.

Example: The Inner Settings Package

The inner folder shares the project's name and holds settings.py, urls.py, wsgi.py, asgi.py, and __init__.py — the actual configuration package.

bash
ls mysite/mysite/

⚠️ Run this in your own terminal or Node.js environment.

What settings.py Controls

settings.py is the central configuration file where you set installed apps, database connections, static file paths, and other project-wide options.

Example: What settings.py Controls

grep-ing settings.py for these names shows exactly where each key project-wide option — installed apps, database connection, middleware stack, template config — is declared.

bash
grep -n "INSTALLED_APPS\|DATABASES\|MIDDLEWARE\|TEMPLATES" mysite/mysite/settings.py

⚠️ Run this in your own terminal or Node.js environment.

The Role of urls.py

The project-level urls.py is the first place Django looks to match an incoming URL, and it typically delegates to each app's own urls.py using include().

Example: The Role of urls.py

The project-level urls.py is the first stop for every request; here it hands off anything under /blog/ to the blog app's own urls.py via include().

markup
# mysite/urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls')),
]
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Confusing the outer project folder with the inner settings package that shares a similar name.
  2. Editing files inside migrations folders by hand instead of letting Django generate them.
  3. Placing app-specific code directly in the project settings folder instead of inside its own app.
Chapter Summary
  • A new project has an outer folder and an inner settings package with the same name.
  • settings.py holds project-wide configuration like installed apps and database settings.
  • urls.py maps URLs to views at the project level.
  • manage.py is the command-line entry point for running the project.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.