@flyeric0212/frameworks-django
Django 后端开发的约定和最佳实践。 globs: **/*.py
prpm install @flyeric0212/frameworks-django0 total downloads
📄 Full Prompt Content
---
description: Django 后端开发的约定和最佳实践。
globs: **/*.py
alwaysApply: false
---
# Django 规则
- 使用 `python manage.py startapp` 在项目中创建新应用
- 在 `models.py` 中保存模型,并在 `admin.py` 中注册以使用管理界面
- 使用 Django 的 ORM 而非原始 SQL 查询
- 使用 `select_related` 和 `prefetch_related` 避免 N+1 查询问题:
```python
# 良好模式
users = User.objects.select_related('profile')
posts = Post.objects.prefetch_related('tags')
```
- 使用 Django 表单进行验证:
```python
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ['username', 'email']
```
- 为常见查询创建自定义模型管理器:
```python
class ActiveUserManager(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(is_active=True)
```
- 使用 Django 内置的身份验证系统
- 在环境变量中存储设置并通过 `settings.py` 访问
═══════════════════════════════════════════════════════════════════
═══ ENGLISH TRANSLATION ═══
═══════════════════════════════════════════════════════════════════
---
description: Frameworks Django Development Guidelines (Translation)
---
# Frameworks Django Guidelines - English Translation
**Note**: This package contains Chinese cursor rules for Frameworks Django.
**Original Language**: Chinese (Simplified)
**Content Summary**: This package provides comprehensive development guidelines, best practices, and coding standards for Frameworks Django. The rules cover code organization, naming conventions, design patterns, testing strategies, and performance optimization.
**Translation Status**: Automated translation placeholder. For accurate technical translation of specific terms and context, please:
1. Use the original Chinese content above as authoritative reference
2. Refer to official Frameworks Django documentation in English
3. The technical patterns and code examples remain universal across languages
**How to Use**:
- Code blocks and examples use universal syntax
- Technical terms (APIs, methods, libraries) are typically in English even in Chinese text
- Structure and organization principles translate directly to English development practices
**Content Length**: 746 characters of detailed technical guidance
For community-contributed English translation, please refer to the source repository.💡 Suggested Test Inputs
Loading suggested inputs...
🎯 Community Test Results
Loading results...
📦 Package Info
- Format
- cursor
- Type
- rule
- Category
- backend-frameworks
- License
- MIT