skillfed

django-patterns

Master production-ready Django patterns covering project structure, model design, QuerySet optimization, and REST Framework integration. Learn configuration management across environments, custom managers, serializers, and middleware strategies for building maintainable, scalable applications.

django-patterns teaches production-grade architecture patterns and best practices for building scalable Django applications.

AI-generated summary based on this skill's SKILL.md

1,767 298 MIT updated by xu-xiang

Install

xu-xiang/everything-claude-code-zh/django-patterns · repository language: JavaScript

git clone https://github.com/xu-xiang/everything-claude-code-zh
cp -r everything-claude-code-zh/skills/django-patterns ~/.claude/skills/django-patterns
npx skillfed install xu-xiang/everything-claude-code-zh/django-patterns

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What are the key django best practices for architecture patterns?

django-patterns teaches production-grade architecture by emphasizing separation of concerns, custom managers for QuerySet optimization, service layers for business logic, and environment-specific configuration management. The skill covers project structure best practices, model design principles, and middleware strategies that ensure maintainability and scalability across development, staging, and production environments.

How do you design and build scalable Django REST Framework APIs?

django-patterns covers DRF API design through viewsets, serializers, and permission classes. You'll learn to structure endpoints for scalability, implement custom serializers for complex data transformations, use permissions and authentication patterns, and design APIs that handle growth without architectural refactoring. The skill includes practical examples of viewset and serializer patterns.

How can I prevent N+1 query problems in django orm optimization?

django-patterns addresses N+1 prevention through select_related and prefetch_related techniques, custom QuerySet managers, and query analysis strategies. You'll learn when to use each optimization method, how to build reusable custom managers, and patterns for identifying performance bottlenecks. The skill emphasizes database indexing and bulk operations for efficient data handling.

What caching strategies and middleware patterns does django-patterns cover?

django-patterns teaches caching implementation at multiple levels: template fragment caching, view-level caching, and query result caching. You'll learn middleware custom implementation for cross-cutting concerns, signal usage for cache invalidation, and configuration patterns for different environments. These strategies improve performance while maintaining data consistency.

How should I structure a django project for maintainability?

django-patterns emphasizes modular app organization, split settings configuration for environment management, service layer patterns for business logic separation, and custom manager usage for data access abstraction. The skill teaches project layout that scales from small applications to large systems, with clear boundaries between models, views, serializers, and business logic.

What model design best practices does django-patterns recommend?

django-patterns covers model design through custom manager patterns, efficient field choices, relationship optimization, and indexing strategies. You'll learn to design models that support both ORM efficiency and API serialization, implement custom QuerySet methods for reusable queries, and structure inheritance hierarchies appropriately for your application's needs.

SKILL.md

rendered from the published skill — quoted content, verbatim

Django 开发模式 (Django Development Patterns)

适用于可扩展、可维护应用程序的生产级 Django 架构模式。

何时激活 (When to Activate)

  • 构建 Django Web 应用程序
  • 设计 Django REST Framework (DRF) API
  • 处理 Django ORM 和模型 (Models)
  • 搭建 Django 项目结构
  • 实现缓存 (Caching)、信号 (Signals)、中间件 (Middleware)

项目结构 (Project Structure)

推荐布局 (Recommended Layout)
myproject/
├── config/
│   ├── __init__.py
│   ├── settings/
│   │   ├── __init__.py
│   │   ├── base.py          # 基础配置
│   │   ├── development.py   # 开发配置
│   │   ├── production.py    # 生产配置
│   │   └── test.py          # 测试配置
│   ├── urls.py
│   ├── wsgi.py
│   └── asgi.py
├── manage.py
└── apps/
    ├── __init__.py
    ├── users/
    │   ├── __init__.py
    │   ├── models.py
    │   ├── views.py
    │   ├── serializers.py
    │   ├── urls.py
    │   ├── permissions.py
    │   ├── filters.py
    │   ├── services.py
    │   └── tests/
    └── products/
        └── ...
配置拆分模式 (Split Settings Pattern)

```python

config/settings/base.py

from pathlib import Path

BASE_DIR =

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
skills/django-patterns/SKILL.md

Related skills

Tags

rest-api-design orm-optimization project-architecture performance-tuning production-ready code-organization query-optimization middleware-patterns business-logic-layer database-indexing