NelsonLabs
Django/Django Apps

Django Apps

A Django project is made of apps โ€” modular components that each handle one area of your site. A blog might have a 'posts' app, a 'comments' app, and an 'accounts' app. This modularity keeps code organised and reusable.

Creating a Django app
bash
python manage.py startapp courses

# App structure:
# courses/
#   __init__.py
#   admin.py      โ† register models for the admin panel
#   apps.py       โ† app configuration
#   models.py     โ† database models
#   views.py      โ† request handlers
#   urls.py       โ† URL patterns (you create this file)
#   tests.py      โ† tests
Register your app
python
# myproject/settings.py โ€” add to INSTALLED_APPS
INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    # ... other built-in apps ...
    "courses.apps.CoursesConfig",  # or just "courses"
]

TIP

One concern per app. A good Django app does one thing well. 'courses' handles courses. 'users' handles user profiles. 'payments' handles billing. This separation means you can test and reason about each area independently โ€” and theoretically reuse apps across projects.