MV

MVC

Used in 205 python projects (avg ★151)

Python
Architecture
Used by 205 projects
webapp
api
cli

Details

Language / Topic
pythonPython
Category
Architecture

Rules

balanced
- In Django: views are controllers, templates are views, models are models. Follow Django's MTV convention.
- In FastAPI/Flask: route handlers are controllers, Jinja templates are views, SQLAlchemy/Pydantic are models.
- Use Pydantic models for request/response schemas and SQLAlchemy models for persistence — never expose ORM models directly in API responses.
- Keep views/route handlers thin: parse input, call service/model methods, return response.
- Put business logic in model methods or service modules — not in views or serializers.
- Use forms (Django) or Pydantic schemas (FastAPI) for input validation at the controller boundary.
- Use template inheritance (`{% extends %}`) for consistent layouts across pages.