模板详情

Django REST API 护栏

帮助 DRF 团队让 AI agent 尊重权限检查、serializer 边界和数据库查询成本。

Claude CodeCursorCodexCLAUDE.mdAGENTS.md
289投票
4,020安装量
观察中状态

安装预览

命令仍是 MVP 预览。真实使用前请检查目标文件和覆盖行为。

npx rulesmarket add django-rest-api-guardrails
返回模板库
CLAUDE.md
# Django REST Framework Rules

- Keep permissions explicit on every viewset and custom action.
- Use serializers for validation and representation; avoid business logic in views.
- Optimize queryset access with select_related and prefetch_related when returning lists.
- Add tests for permissions, validation and serializer edge cases.
- Do not change migrations or settings without explaining the operational impact.
- Avoid exposing internal model fields in API responses.

为什么标记为观察中?

它还需要在更多 DRF 项目结构中验证,才能作为生产默认模板。

它默认使用 class-based views 吗?

它主要面向 serializers 和 viewsets,但原则也适用于函数式端点。