</>
Skip to content
Django lessons (7/43)

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

  1. Keep apps small and focused
  2. Use meaningful app names
  3. Separate settings by environment
  4. Organize templates by app
  5. Use static files properly

Mini Practice

  1. Create the recommended structure
  2. Split settings into files
  3. Organize templates
  4. 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.