Django 遵循 MVT (Model-View-Template) 架构 — 这是对经典 MVC 模式的改进。它将应用程序分为三个层:Models(数据)、Views(逻辑)和 Templates(展现)。理解这些层可以明确每段代码的位置。
三个层
text
Model → the DATA layer: defines structure & talks to the database (the ORM)
View → the LOGIC layer: processes requests, fetches data, returns responses
Template → the PRESENTATION layer: HTML with placeholders for dynamic data
