提供github文件夹的copilot配置模板
This commit is contained in:
14
.github/instructions/django-drf.instructions.md
vendored
Normal file
14
.github/instructions/django-drf.instructions.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
applyTo: "**/*.py"
|
||||
description: "用于 Django/DRF 实现,关键词:Thin View Fat Service、ModelViewSet、Serializer、权限隔离"
|
||||
---
|
||||
|
||||
# Django/DRF 约束
|
||||
|
||||
- 严格执行 Thin View, Fat Service:复杂业务逻辑进入 Service 层。
|
||||
- Model 定义显式字段与约束;Serializer 禁止 `fields = '__all__'`。
|
||||
- 列表查询必须考虑 `select_related` / `prefetch_related` 防 N+1。
|
||||
- 视图层通过 `get_queryset`、`get_permissions`、`get_serializer_class` 管理数据范围与权限。
|
||||
- 禁止在 View 中手工拼装错误响应,统一交由异常处理与全局响应包装。
|
||||
- URL 命名与版本化保持一致,非标准接口补充 `@extend_schema`。
|
||||
- 参考规范:`03 - Coding & Frameworks/02 - Framework Development Specification/Django_DRF开发规范.md`。
|
||||
Reference in New Issue
Block a user