MVT pattern Django

2017-07-25  本文已影响16人  Zihowe

MVC

传统的MVC模式指的是model,view,controller

MVT

Django中的MVT模式指的是model,view,template

Django is a "MTV" framework – that is, “model”, “template”, and “view.”

The "view" describes the data that gets presented to the user. It’s not necessarily how the data looks, but which data is presented. The view describes which data you see, not how you see it. It’s a subtle distinction.
So, in our case, a view is the Python callback function for a particular URL, because that callback function describes which data is presented.

Furthermore, it’s sensible to separate content from presentation – which is where templates come in. In Django, a view describes which data is presented, but a view normally delegates to a template, which describes how the data is presented.

Where does the controller fit in, then? In Django’s case, it’s probably the framework itself: the machinery that sends a request to the appropriate view, according to the Django URL configuration.
Reference:
https://docs.djangoproject.com/en/1.11/faq/general/

上一篇 下一篇

猜你喜欢

热点阅读