django-patterns

Implements Django architecture patterns for REST APIs, ORM optimization, caching, and production applications.

2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/adamreger/ecc-antigravity --skill django-patterns-adamreger
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: django-patterns
Source: https://github.com/adamreger/ecc-antigravity/tree/main/skills/django-patterns
Command: npx skills add https://github.com/adamreger/ecc-antigravity --skill django-patterns-adamreger

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building maintainable Django applications requires consistent architecture decisions across project structure, models, APIs, and performance optimization, which developers often reinvent or get wrong. ## Core Features & Use Cases - Project Structure & Settings: Provides split settings patterns (base/development/production) and a scalable app layout for Django projects. - DRF API Design: Covers serializers, ViewSets, custom actions, validation, and permission patterns for Django REST Framework endpoints. - ORM & Performance: Includes custom QuerySets, managers, select_related/prefetch_related usage, indexing, and bulk operations to prevent N+1 queries. - Use Case: When building a new e-commerce API, apply the service layer pattern to separate order creation logic from views, use custom QuerySets to avoid N+1 queries on product listings, and cache expensive category aggregations. ## Quick Start Use the django-patterns skill to design a Django REST Framework API with proper model structure, serializers, and query optimization for my project.

Frequently Asked Questions about django-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Django project for production?▼

Use a config package with split settings files (base.py, development.py, production.py, test.py) and organize business logic into an apps directory. Each app contains models, views, serializers, services, and tests for clear separation of concerns.

How to avoid N+1 queries in Django ORM?▼

Use select_related for foreign key relationships and prefetch_related for many-to-many fields when querying. Encapsulate these in custom QuerySet methods like with_category() so optimization is applied consistently across the codebase.

What is the service layer pattern in Django?▼

The service layer pattern moves business logic out of views and models into dedicated service classes, such as an OrderService handling order creation and payment processing. This keeps views thin and makes complex operations testable and reusable.

Does Django REST Framework support custom ViewSet actions?▼

Yes, use the @action decorator to add custom endpoints to ViewSets, such as a purchase action on a product or a featured list endpoint. Actions support detail routes, custom HTTP methods, and per-action permission classes.

When should I use Django signals versus direct method calls?▼

Signals suit decoupled side effects like creating a user profile on user registration via post_save. For core business flows, direct service method calls are preferable because signals can obscure execution order and complicate debugging.