成人免费无码不卡毛片,亚洲AⅤ无码精品一区二区三区,国产尤物精品视频,久久精品日本亚洲,欧美成人一区三区无码乱码A片,中文字日产幕码一区二区色哟哟,亞洲日韓中文字幕網AV

  • 正文
    • MTV模型
  • 相關推薦
申請入駐 產(chǎn)業(yè)圖譜

Django讓web開發(fā)更簡單(二):了解MVT模式

2024/10/05
861
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論

前情提示

上一章節(jié),我們“重頭到尾”把前后端不分離的開發(fā)模型MTV(也有叫MVT)擼了一遍,發(fā)現(xiàn)跟java的MVC模型(這里不講解)很像。

官方文檔不采用MVC的說法,而采用MTV的說法,原因也有說明,以下是原話:

(地址:https://docs.djangoproject.com/en/3.1/faq/general/)

Django appears to be a MVC framework, but you call the Controller the “view”, and the View the “template”. How come you don’t use the standard names??
Well, the standard names are debatable.

In our interpretation of MVC, 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.

If you’re hungry for acronyms, you might say that Django is a “MTV” framework – that is, “model”, “template”, and “view.” That breakdown makes much more sense.

At the end of the day, it comes down to getting stuff done. And, regardless of how things are named, Django gets stuff done in a way that’s most logical to us.

從定義上,django開發(fā)團隊,覺得自己更嚴謹。

定義一個事物,是一件很重要的事情。如果你定義了一個東西,大家都這么叫,以后說什么都是占據(jù)主動權,因為你是鼻祖!所以,定義是個偉大的事情,讓你具有降維打擊的主動權。

此為,前話。

MTV模型

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

模型(model):用于操作數(shù)據(jù)庫
模板(template):用于展示數(shù)據(jù)
視圖(view):用于控制業(yè)務邏輯

工作流程圖如下:

在這里插入圖片描述

了解django的工作機制,可以更好的進行開發(fā),即以一個全局觀的思維去看待django的,你就知道要開發(fā)和運行django服務,需要做什么了。

相關推薦

天等县| 本溪市| 石台县| 杭锦后旗| 汶上县| 淄博市| 务川| 阿尔山市| 望江县| 济阳县| 潞城市| 天长市| 岐山县| 永康市| 汶川县| 柘荣县| 黄平县| 沙坪坝区| 蓝田县| 麻江县| 安顺市| 武宣县| 西平县| 六枝特区| 榆树市| 泾源县| 都兰县| 怀化市| 左权县| 沁源县| 大新县| 牟定县| 蒙城县| 霍山县| 民乐县| 辽阳市| 阆中市| 临沧市| 恩施市| 自治县| 乐昌市|