Django — Structure
Recommended Structure
mysite/
├── manage.py
├── requirements.txt
├── .env
├── mysite/
│ ├── __init__.py
│ ├── settings/
│ │ ├── base.py
│ │ ├── development.py
│ │ └── production.py
│ ├── urls.py
│ ├── wsgi.py
│ └── asgi.py
├── apps/
│ ├── blog/
│ ├── accounts/
│ └── core/
├── templates/
├── static/
├── media/
└── locale/
Settings Split
# settings/base.py
INSTALLED_APPS = [...]
MIDDLEWARE = [...]
# settings/development.py
from .base import *
DEBUG = True
DATABASES = {...}
# settings/production.py
from .base import *
DEBUG = False
ALLOWED_HOSTS = [...]
Static Files
static/
├── css/
│ └── style.css
├── js/
│ └── main.js
└── images/
└── logo.png
Templates
templates/
├── base.html
├── blog/
│ ├── list.html
│ └── detail.html
└── accounts/
└── profile.html
Best Practices
- Keep apps small and focused
- Use meaningful app names
- Separate settings by environment
- Organize templates by app
- Use static files properly
Mini Practice
- Create the recommended structure
- Split settings into files
- Organize templates
- Set up static files
Up Next
Continue with Settings — Django configuration options.
Related Topics
Frequently Asked Questions about Structure
What is Structure in Django?
Structure is a fundamental concept in Django. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Structure?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Structure.
Why is Structure important in Django?
Structure is essential for Django development. Understanding this concept will help you write better code and solve real-world problems more effectively.