A Django App is a self-contained, modular Python package within a Django project that provides a specific set of features or domain logic, typically containing its own models, views, templates, and URLs.
Apps are the building blocks of a Django project. If you are building an e-commerce site, you might have one app for users, one app for products, and one app for billing. This modularity makes code easier to maintain and reuse.
- Created using
python manage.py startapp <appname>. - Generates a directory with
models.py,views.py,admin.py, andapps.py. - The app must be registered in the project’s
settings.pyunderINSTALLED_APPS. - Its URLs are usually included in the project’s root
urls.py.
graph TD A[Django App] --> B(models.py) A --> C(views.py) A --> D(urls.py) A --> E(admin.py)
If a Django Project is a company, a Django App is a specific department (e.g., HR, Accounting, Sales). Each department has its own specific job, its own files, and its own processes, but they all work together under the company.
python manage.py startapp usersRegistering in settings.py:
INSTALLED_APPS = [
# ...
'users',
]- Modular and reusable.
- Contains domain-specific logic.
- Has its own models and views.
- Built from: Django Project — lives inside a project.
- Builds into: Django Model — apps define models.
- Builds into: Django View — apps define views.
- Contrasts with: Django Project — app is specific, project is global.
- If an app is not added to
INSTALLED_APPS, Django will not recognize its models or templates.