Creating an App

Split your project into reusable apps with startapp.

Syntaxpython 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

Example · bash
# 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.

Example · bash
python manage.py startapp blog
# Creates: blog/__init__.py, models.py, views.py, apps.py, admin.py, tests.py

Register app in INSTALLED_APPS

Registers the new app with Django so models, migrations, and admin integrations are recognized.

Example · python
# 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.

Example · python
# 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

  • Be the first to comment on this lesson.