Python Django Cursor Rules Template for Personalized Learning Path Tools
Cursor Rules Template for a Django-based personalized learning path tool designed for training institutes. Includes a .cursorrules block and stack-specific guidance.
Target User
Backend engineers, AI/ML engineers, and platform architects building learning path systems in Django.
Use Cases
- Personalized course sequencing
- Adaptive learning paths
- Enrollment and progress tracking
- Recommendations
Markdown Template
Python Django Cursor Rules Template for Personalized Learning Path Tools
# Copyable Cursor Rules for Django Learning Path Tool
# Framework: Django, PostgreSQL, Django REST Framework
framework: Django
frameworkContext: "You are an AI coding assistant building a Django-based personalized learning path tool for training institutes. Follow safety and architecture rules; avoid unsafe patterns."
# Code Style and Style Guides
styleGuide:
language: Python
standards: ["PEP8", "Black", "isort"]
# Architecture & Directory Rules
architecture:
projectRoot: "learning_path_tool"
apps:
- core
- learners
- paths
- recommendations
directories:
- templates/
- static/
api:
method: REST
auth: JWT (DRF SimpleJWT)
# Authentication & Security Rules
authentication:
method: JWT
cookies: secure
csrf: true
allowedOrigins: ["https://suhasbhairav.com"]
forbiddenActions: ["executes arbitrary shell commands", "exfiltrates secrets"]
# Database and ORM patterns
database:
orm: Django ORM
models:
- User
- LearnerProfile
- InstructorProfile
- LearningPath
- PathModule
- Lesson
- Assessment
- Enrollment
migrations: auto
migrationsCI: true
# Testing & Linting Workflows
testing:
unit:
- tests/models.py
- tests/serializers.py
integration:
- tests/api/test_paths.py
ci:
- pytest-django
- mypy
linting:
precommit: true
tools: [ruff, black, isort]
# Prohibited Actions and Anti-patterns for the AI
antiPatterns:
- "Do not bypass authentication or perform privileged actions"
- "Do not execute shell commands in AI-generated code"
- "Do not embed secrets or credentials in code or configs"Overview
Cursor rules configuration for a Django-based personalized learning path tool helps training institutes generate adaptive course sequences, track learner progress, and provide AI-assisted recommendations. This Cursor rules template defines stack-specific roles, architecture, and safety constraints to ensure production-ready results while enabling Cursor AI to reason within Django, PostgreSQL, and DRF boundaries.
When to Use These Cursor Rules
- Designing a Django REST API to deliver personalized learning paths for cohorts of learners.
- Integrating with PostgreSQL via Django ORM for scalable student data and path metadata.
- Implementing AI-assisted sequencing and recommendations with Cursor AI while preserving data privacy.
- Establishing security, auditing, and testing workflows in a Django project lifecycle.
- Defining project structure and CI/CD practices for a learning-path service in training institutes.
Copyable .cursorrules Configuration
# Copyable Cursor Rules for Django Learning Path Tool
# Framework: Django, PostgreSQL, Django REST Framework
framework: Django
frameworkContext: "You are an AI coding assistant building a Django-based personalized learning path tool for training institutes. Follow safety and architecture rules; avoid unsafe patterns."
# Code Style and Style Guides
styleGuide:
language: Python
standards: ["PEP8", "Black", "isort"]
# Architecture & Directory Rules
architecture:
projectRoot: "learning_path_tool"
apps:
- core
- learners
- paths
- recommendations
directories:
- templates/
- static/
api:
method: REST
auth: JWT (DRF SimpleJWT)
# Authentication & Security Rules
authentication:
method: JWT
cookies: secure
csrf: true
allowedOrigins: ["https://suhasbhairav.com"]
forbiddenActions: ["executes arbitrary shell commands", "exfiltrates secrets"]
# Database and ORM patterns
database:
orm: Django ORM
models:
- User
- LearnerProfile
- InstructorProfile
- LearningPath
- PathModule
- Lesson
- Assessment
- Enrollment
migrations: auto
migrationsCI: true
# Testing & Linting Workflows
testing:
unit:
- tests/models.py
- tests/serializers.py
integration:
- tests/api/test_paths.py
ci:
- pytest-django
- mypy
linting:
precommit: true
tools: [ruff, black, isort]
# Prohibited Actions and Anti-patterns for the AI
antiPatterns:
- "Do not bypass authentication or perform privileged actions"
- "Do not execute shell commands in AI-generated code"
- "Do not embed secrets or credentials in code or configs"
Recommended Project Structure
learning_path_tool/
├── manage.py
├── requirements.txt
├── learning_path_tool/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ ├── core/
│ │ ├── models.py
│ │ ├── serializers.py
│ │ └── views.py
│ ├── learners/
│ │ ├── models.py
│ │ ├── serializers.py
│ │ └── views.py
│ ├── paths/
│ │ ├── models.py
│ │ ├── serializers.py
│ │ └── views.py
│ └── recommendations/
│ ├── models.py
│ ├── serializers.py
│ └── views.py
├── templates/
└── static/
Core Engineering Principles
- Clear separation of concerns: distinct Django apps for core data, paths, and recommendations.
- Defensive coding: input validation, strict serializers, and safe AI prompts.
- Data privacy by design: minimal data exposure, per-request access checks, and audit logging.
- Reproducible deployments: pinned dependencies and CI-tested migrations.
- Observability: structured logging, metrics, and error tracing for API endpoints.
Code Construction Rules
- Use Django ORM models with clear foreign-key relations for LearnerProfile, LearningPath, and Enrollment.
- Expose only necessary endpoints via DRF viewsets; prefer serializers with explicit fields.
- Validate all input with DRF serializers; reject unexpected fields to prevent overposting.
- Implement per-user authorization checks for path creation and modification.
- Encapsulate AI-assisted logic in service-layer utilities, not in views.
- Document API contracts with OpenAPI/Swagger via DRF schemas.
- Do not hard-code secrets; use environment variables and secret managers.
Security and Production Rules
- Enforce HTTPS, secure cookies, and CSRF protection for browser clients.
- Limit request rates on learning path endpoints to prevent abuse.
- Store only necessary data; encrypt sensitive fields at rest where applicable.
- Regularly rotate API keys and use per-request short-lived tokens for Cursor AI calls.
- Audit logs for learning path changes and AI-generated recommendations.
Testing Checklist
- Unit tests for models, serializers, and small utilities.
- Integration tests for path creation, enrollment flow, and recommendations endpoints.
- CI workflow runs migrations, linting, and tests on pull requests.
- Security tests for JWT auth, CSRF, and access control.
- End-to-end tests for a typical learner journey (sign up, enroll, view path).
Common Mistakes to Avoid
- Embedding AI prompts directly in view logic without a service layer.
- Overexposing API data or bypassing authentication on critical endpoints.
- Ignoring migrations in production deployments and accumulating schema drift.
- Storing credentials in code or logs; lack of secret management.
- Not validating inputs leading to unsafe query construction or overposting.
Related implementation resources: AI Agent Use Case for Training Institutes Using Student Performance Data to Recommend Personalized Learning Paths and Skill libraries for production-grade AI delivery in modern development teams.
FAQ
What is the Cursor Rules Template for Django learning path tools?
The template defines a Django-based stack with clear architecture, authentication, ORM usage, and a copyable .cursorrules block to guide AI-assisted development of personalized learning paths for training institutes.
Which technologies does this template assume?
It assumes Django, PostgreSQL, and Django REST Framework, with a clear separation of apps for core data, paths, learners, and recommendations. It emphasizes safe AI prompts and testing workflows within this stack.
How do I use the included .cursorrules block?
Paste the block into your project root as .cursorrules and customize directories, models, and endpoints to fit your project while following the prescribed rules for architecture and security.
Can this template support multi-institute deployments?
Yes. It includes per-institute data separation in models and scope-limited APIs, with per-tenant considerations and configurable permissions in DRF serializers.
How do I ensure data privacy and compliance?
Rely on per-user authentication, restricted read/write access, encrypted sensitive fields, and audited actions. Do not log secrets or expose PII in API responses.