Django Project Structure
In this page:
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.
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.
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.
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().
# 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. #}
- Confusing the outer project folder with the inner settings package that shares a similar name.
- Editing files inside migrations folders by hand instead of letting Django generate them.
- Placing app-specific code directly in the project settings folder instead of inside its own app.
- 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.
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: