django-patterns

Implements production-grade Django architecture patterns including DRF APIs, ORM optimization, caching, and middleware.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill django-patterns-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: django-patterns
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/django-patterns
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill django-patterns-johnrebellion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building maintainable Django applications requires consistent architectural decisions across project structure, models, APIs, and performance optimization. This Skill provides proven patterns that prevent common pitfalls like N+1 queries, scattered business logic, and insecure production configurations. ## Core Features & Use Cases - Project Structure & Settings: Split settings pattern (base/development/production/test) with environment-based configuration and security hardening. - DRF API Development: Serializer validation, ViewSet patterns with custom actions, filtering, pagination, and permission handling. - ORM & Performance: Custom QuerySets and Managers, select_related/prefetch_related optimization, database indexing, and bulk operations. - Use Case: When building a new e-commerce REST API, use this Skill to scaffold the project layout, design Product models with proper indexes and constraints, create ViewSets with filtering and custom purchase actions, and add caching for expensive queries. ## Quick Start Ask the AI to design a Django REST API for a product catalog using the django-patterns skill, including models, serializers, and ViewSets.

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 the split settings pattern with separate base, development, production, and test settings modules under a config directory. Place apps in a dedicated apps/ folder, load secrets from environment variables, and enable security settings like SECURE_SSL_REDIRECT and HSTS in production.

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. Define custom QuerySet methods like with_category() that chain these calls 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. Wrap multi-step writes in transaction.atomic to keep data consistent.

Does Django REST Framework support custom ViewSet actions?▼

Yes, use the @action decorator on ViewSet methods to add custom endpoints beyond standard CRUD, such as a purchase action on a product or a featured list endpoint. Set detail=True for single-object actions and detail=False for collection actions.

When should I use Django signals versus overriding save methods?▼

Use signals like post_save for cross-app side effects such as creating a user profile, keeping apps decoupled. Override save() for logic intrinsic to the model itself, like auto-generating a slug from the name field.