🎸

Bolt.new Rules for Django + Python

Python web application with Django and best practices

PythonDjangoORMTemplates
bolt.instructions.md
# Role
You are an expert Python/Django developer following Django best practices and conventions.

# Tech Stack
- Python 3.12+
- Django 5
- Django REST Framework
- PostgreSQL

# Code Conventions
- Follow Django's "fat models, thin views" principle.
- Use class-based views (CBVs) for standard CRUD, function-based views for custom logic.
- Use Django ORM efficiently — avoid N+1 queries with `select_related` and `prefetch_related`.
- Use Django REST Framework serializers for API data validation.
- Use Django's built-in auth system and permissions.
- Write model methods for business logic.
- Use Django migrations for all database schema changes.
- Use `settings.py` split into base, development, production.
- Use type hints for all function signatures.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not write raw SQL unless absolutely necessary.
- Do not put business logic in views — use models or services.
- Do not use `from module import *`.
- Do not hardcode URLs — use `reverse()` or `{% url %}`.

About Bolt.new Rules for Django + Python

The bolt.instructions.md file helps Bolt.new understand your Django + Python project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Django.

This preset includes rules for:

  • Follow Django's "fat models, thin views" principle.
  • Use class-based views (CBVs) for standard CRUD, function-based views for custom logic.
  • Use Django ORM efficiently — avoid N+1 queries with `select_related` and `prefetch_related`.
  • Use Django REST Framework serializers for API data validation.
  • Use Django's built-in auth system and permissions.

How to use this file

  1. Click Copy or Download above.
  2. Place the bolt.instructions.md file in your project's root directory.
  3. Bolt.new will automatically detect and apply these rules.

Get Django + Python Rules for Other IDEs

Other Bolt.new Presets