django-dev-ninja

Category: Testing & Security | Uploader: sergio-bershadskysergio-bershadsky | Downloads: 0 | Version: v1.0(Latest)

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. --- # 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",

Changelog: Source: GitHub https://github.com/sergio-bershadsky/ai

Directory Structure

Current level: tree/main/plugins/django-dev/skills/django-dev-ninja/

SKILL.md

Login to download/like/favorite ❤ 8 | ★ 0
Comments 0

Please login before commenting.

No comments yet. Be the first one!