Django follows this MVC pattern closely enough that it can be called an MVC framework. Here’s roughly how the M, V, and C break down in Django:
Neither interpretation is more “correct” than the other. The important thing is to understand the underlying concepts.
- M, the data-access portion, is handled by Django’s database layer, which is described in this chapter.
- V, the portion that selects which data to display and how to display it, is handled by views and templates.
- C, the portion that delegates to a view depending on user input, is handled by the framework itself by following your URLconf and calling the appropriate Python function for the given URL.
- M stands for “Model,” the data access layer. This layer contains anything and everything about the data: how to access it, how to validate it, which behaviors it has, and the relationships between the data.
- T stands for “Template,” the presentation layer. This layer contains presentation-related decisions: how something should be displayed on a Web page or other type of document.
- V stands for “View,” the business logic layer. This layer contains the logic that access the model and defers to the appropriate template(s). You can think of it as the bridge between models and templates.
Neither interpretation is more “correct” than the other. The important thing is to understand the underlying concepts.
References
- http://www.djangobook.com/en/2.0/chapter05.html#the-mtv-or-mvc-development-pattern
- http://reinout.vanrees.org/weblog/2011/12/13/django-mvc-explanation.html
- http://stackoverflow.com/questions/6621653/django-vs-model-view-controller
No comments:
Post a Comment