CodeOath
← All posts
Python70 min total · 18 parts

Django Fundamentals: MVT Architecture, the ORM, and Middleware

Contents — Part 2 of 18: MVT, Mapped to the MVC You Already Know
Part 2 of 18 · ~1 min

MVT, Mapped to the MVC You Already Know

Django termRoleRoughly equivalent to
ModelDefines data structure, talks to the databaseModel (same as MVC)
ViewContains the logic — decides what data to fetch and which template to renderController (confusingly, not the "View" in MVC)
TemplateThe HTML, with minimal logic, that renders the responseView (the actual MVC "View")

Django's "View" does what MVC calls the "Controller"; Django's "Template" does what MVC calls the "View." Once that swap clicks, everything else about Django's structure is exactly what you'd expect. Django also ships its own request-routing layer (urls.py), which most MVC diagrams fold into "the controller" but Django keeps as an explicit, separate step.