The MTV pattern

Certify and Increase Opportunity.
Be
Govt. Certified Django Developer

The MTV pattern

the RSS feed for Steve Smith’s great Ordered List blog decided to tell me a whole bunch of items were new, when they really weren’t. I’m not sure why that happened, but I’m glad it did. It resulted in my discovery of an entry he wrote back in November entitled Rails and MVC. Steve notes that several people toy with Rails a bit, but never get very far, and concludes that part of the reason for this is their lack of understanding of the Model-View-Controller programming design pattern.

15

Steve goes on to outline what MVC is and how it applies specifically to Ruby on Rails. It struck me that a similar piece for Django might be useful, especially since Django breaks slightly from the traditional definition of MVC. In Django, it’s MTV.

The best way to describe the MVC concept to the audience of this blog is with an analogy: MVC strives to rectify many of the same problems that the web standards movement tried to solve on the front end of things. Largely, MVC is about the separation of the different layers of a program. Just as the web standards movement was largely about breaking apart the content, presentation, and behavior layers of a web document, MVC is all about a clean break between the data, the logic that occurs around that data when a user interacts with an application, and the presentation of that data to the user. Just like web standards, right? Right.

Django is usually called an MVC framework, and justifiably so. It’s very heavily influenced by MVC and it’s even possible to argue that terminology is only place Django changes the pattern. In Django, the three core layers are the Model, the View, and the Template.

Share this post
[social_warfare]
Interacting with a Database: Models
Database Configuration

Get industry recognized certification – Contact us

keyboard_arrow_up