程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django framework web development practice: Django view and URL configuration and request methods (2)

編輯:Python

Django view and URL configuration

I. MTV mode

1. Overview

Django's MTV mode is essentially the same as MVC, and it is also to maintain a loosely coupled relationship between components, but the definition is slightly different. Django's MTV is the value:

  • **M stands for Model: **Responsible for relational mapping (ORM) between business objects and databases.
  • **T stands for Template: **Responsible for how the page is displayed to the user (html).
  • V stands for View: responsible for business logic and calling Model and Template when appropriate.

The View component is provided in Django to act as a C-controller in MVC.

2. The main responsibilities of the view

  • Receive request
  • Scheduling Model, processing business logic
  • Response request/forward Template (display data related logic)

Second, the basic development process

1. Create an App and define functions in the view

In the views.py of each App, define a hello function

def hello(request)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved