django

仓库创建 2026年4月30日最近提交 22 天前SkillHot 收录 22 天前
▸ 精选理由

专门面向 Django 的查询与结构优化,适合大型项目维护

这个 Skill 做什么

Django 框架的最佳实践路由,指导 ORM、QuerySet、视图与业务决策提取

在 Django 项目里把 ORM 逻辑、QuerySet/Manager 设计、重复的过滤器或 select_related/prefetch_related 从 view、GraphQL resolver、DRF serializer 等处抽出来并规范到模型层的谓词和策略。常用场景是发现大量重复查询、隐含的状态或权限分支,或要强化 django-stubs/mypy 的 ORM typing。特点是保留可观察行为、配套聚焦测试,并用代码级分析工具做安全、可回退的重构。

▸ 展开 SKILL.md 英文原文

Use when working in Django projects on ORM/query placement, custom QuerySet or Manager design, extracting repeated filters/select_related/prefetch_related/orderings from views, GraphQL resolvers, API actions, services, tasks, or query modules, OR extracting hidden business decisions (implicit if-branches over status/ordinal/role, view.action-keyed permission dispatch, deputy/proxy resolution) out of DRF viewsets/serializers/permissions into named predicates and policies on the owning model. Preserves observable behavior with focused tests and verifies with project-local lint/type/boundary checks. Trigger for Django best practices, django-stubs/mypy ORM typing, queryset-scope refactors, model-owned table scopes, read-model query boundaries, DRF adapter thinning, named authorization predicates, and avoiding misplaced business/query logic. Uses ast-grep for structural search when locating repeated query patterns or decision branches across views, serializers, and permissions.

开发编程DjangoORM 优化查询抽取通用
0
Stars
0
Forks
16
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/Eotel/skills/main/django/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/Eotel/skills/main/django/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Django

Use this skill as a compact router for Django best practices. Load the relevant
reference file before changing code; keep project-specific architecture rules
from the target repository authoritative.

> **Locating patterns:** when finding repeated filters/`select_related` chains or
> status/role decision branches across many views, serializers, or permissions,
> use the **`ast-grep`** skill for AST-shape search (and codemods) rather than text
> grep — it catches call variants, kwargs reordering, and aliased imports.

## Operating Rules

1. Orient on the project first.
   - Read `AGENTS.md`, architecture docs, Django settings/test layout, model
     placement rules, and nearby tests
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有