Project Structure
Understand the files Django generates and what each one does.
A fresh Django project has a small, predictable layout. Knowing what each file does saves confusion later.
| File | Purpose |
|---|---|
manage.py | Command-line utility (runserver, migrate, etc.). |
settings.py | All project configuration. |
urls.py | The root URL routing table. |
wsgi.py | Entry point for WSGI servers (production). |
asgi.py | Entry point for ASGI/async servers. |
Your project is made of one or more apps, each a self-contained folder of related features.
Example
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
asgi.py
wsgi.pyWhen to use it
- A new Django developer learns which file to edit for URL routing by understanding the project structure.
- A team lead explains the purpose of manage.py and the inner config package during code onboarding.
- A developer knows to add apps to INSTALLED_APPS in settings.py after studying the project layout.
More examples
Project directory tree
Shows the files Django generates and the role each one plays in the project.
mysite/
manage.py # CLI entry point
mysite/
__init__.py
settings.py # project configuration
urls.py # root URL router
asgi.py
wsgi.pyCommon manage.py commands
Lists the most frequently used manage.py sub-commands every Django developer needs daily.
python manage.py runserver
python manage.py makemigrations
python manage.py migrate
python manage.py shellRoot urls.py wires up apps
The root URLconf delegates URL prefixes to individual app URL modules using include().
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("blog/", include("blog.urls")),
]
Discussion