Creating an App
Split your project into reusable apps with startapp.
Syntax
python manage.py startapp <name>A Django project is a collection of apps. Each app is a self-contained module for one area of functionality — a blog, a shop, an accounts system. Create one with startapp.
After creating it, register the app by adding its name to INSTALLED_APPS in settings.
Example
# Create an app called 'blog'
python manage.py startapp blog
# It creates:
# blog/
# __init__.py
# admin.py
# apps.py
# models.py
# tests.py
# views.py
# migrations/When to use it
- A developer creates a 'blog' app inside a Django project to group all blog-related models, views, and URLs.
- A team organizes a large e-commerce site into separate 'products', 'orders', and 'accounts' apps for clarity.
- A developer generates a new 'notifications' app and immediately registers it in INSTALLED_APPS to enable migrations.
More examples
Create a new app
Generates the standard Django app skeleton with all required module files.
python manage.py startapp blog
# Creates: blog/__init__.py, models.py, views.py, apps.py, admin.py, tests.pyRegister app in INSTALLED_APPS
Registers the new app with Django so models, migrations, and admin integrations are recognized.
# settings.py
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
# ...
"blog.apps.BlogConfig", # register the new app
]Custom AppConfig class
Uses AppConfig.ready() to connect signal handlers when the app finishes loading.
# blog/apps.py
from django.apps import AppConfig
class BlogConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "blog"
def ready(self):
import blog.signals # noqa: F401
Discussion