This skill should be used when the user asks to "create api endpoint", "django ninja", "django api", "add endpoint", "rest api django", "ninja router", "api schemas", or mentions API development, endpoint organization, or Pydantic schemas in Django projects. Provides Django Ninja patterns with 1-endpoint-per-file organization.
View on GitHubFebruary 2, 2026
Select agents to install to:
npx add-skill https://github.com/sergio-bershadsky/ai/blob/main/plugins/django-dev/skills/django-dev-ninja/SKILL.md -a claude-code --skill django-dev-ninjaInstallation paths:
.claude/skills/django-dev-ninja/# Django Ninja API Development
Opinionated Django Ninja patterns with single-endpoint-per-file organization.
## Core Principles
1. **One endpoint = one file** - Each endpoint lives in its own file
2. **Logical grouping** - Endpoints grouped in subpackages by domain
3. **Router per group** - Each group has its own router
4. **Schemas in separate package** - Pydantic models in `schemas/`
5. **Services for logic** - Business logic in services, not endpoints
## API Structure
```
myapp/
├── api/
│ ├── __init__.py # Main NinjaAPI instance
│ ├── users/
│ │ ├── __init__.py # Router: users_router
│ │ ├── list.py # GET /users/
│ │ ├── detail.py # GET /users/{id}
│ │ ├── create.py # POST /users/
│ │ ├── update.py # PUT /users/{id}
│ │ └── delete.py # DELETE /users/{id}
│ ├── products/
│ │ ├── __init__.py
│ │ ├── list.py
│ │ ├── detail.py
│ │ └── search.py
│ └── auth/
│ ├── __init__.py
│ ├── login.py
│ ├── logout.py
│ └── refresh.py
└── schemas/
├── __init__.py
├── user.py # UserIn, UserOut, UserPatch
├── product.py
└── common.py # Pagination, errors
```
## Main API Setup
In `api/__init__.py`:
```python
from ninja import NinjaAPI
from ninja.security import HttpBearer
from .users import router as users_router
from .products import router as products_router
from .auth import router as auth_router
class AuthBearer(HttpBearer):
def authenticate(self, request, token):
# Token validation logic
from ..services.auth import AuthService
return AuthService.validate_token(token)
api = NinjaAPI(
title="My API",
version="1.0.0",
description="API documentation",
auth=AuthBearer(),
)
# Register routers
api.add_router("/users", users_router, tags=["Users"])
api.add_router("/products", products_router, tags=["Products"])
api.add_router("/auth", auth_router, tags=["Authe