| name | django-new-app |
| description | Create a new Django app following modern best practices and cookiecutter-django conventions |
| disable-model-invocation | true |
| argument-hint | [app-name] |
| allowed-tools | Read, Write, Edit, Bash, Grep, Glob |
Create a New Django App
Follow these steps exactly to scaffold a new Django app.
Step 1: Determine App Name
- Use short, lowercase names (no underscores if possible):
orders, payments, notifications.
- The app name should be a plural noun describing the domain.
Step 2: Create the App
mkdir -p <app_name>
python manage.py startapp <app_name> ./<app_name>
Step 3: Create Full Directory Structure
<app_name>/
├── __init__.py
├── admin.py
├── apps.py
├── models.py
├── views.py
├── urls.py
├── serializers.py # if API app
├── services.py # business logic
├── selectors.py # query logic
├── forms.py # if template-based
├── signals.py # if needed
├── tasks.py # background tasks
├── managers.py # custom model managers (or keep in models.py)
├── constants.py # app-level constants
├── migrations/
│ └── __init__.py
├── templates/
│ └── <app_name>/
│ └── .gitkeep
├── static/
│ └── <app_name>/
│ └── .gitkeep
└── tests/
├── __init__.py
├── conftest.py
├── factories.py
├── test_models.py
├── test_views.py
├── test_services.py
└── test_serializers.py # if API app
Step 4: Configure apps.py
from django.apps import AppConfig
class <AppName>Config(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "<app_name>"
verbose_name = "<Human Readable Name>"
def ready(self):
try:
import <app_name>.signals
except ImportError:
pass
Step 5: Register in Settings
Add to config/settings/base.py:
LOCAL_APPS = [
...
"<app_name>",
]
Step 6: Create urls.py
from django.urls import path
from . import views
app_name = "<app_name>"
urlpatterns = [
]
Step 7: Include in Root URLs
In config/urls.py:
urlpatterns = [
...
path("<app_name>/", include("<app_name>.urls")),
]
Step 8: Create services.py Template
"""
Business logic for <app_name>.
All write operations and complex business logic should live here.
Views call these functions — they do not contain logic directly.
"""
from django.db import transaction
Step 9: Create selectors.py Template
"""
Query logic for <app_name>.
All read operations and complex queries should live here.
Views and serializers call these functions for data retrieval.
"""
Step 10: Create admin.py Template
from django.contrib import admin
Step 11: Create tests/conftest.py
import pytest
Step 12: Create tests/factories.py
import factory
from factory.django import DjangoModelFactory
Step 13: Run Verification
python manage.py check
python manage.py makemigrations <app_name>
python manage.py migrate
pytest <app_name>/tests/ -v
Checklist