7.2. Introduction to Django

发布时间 : 2025-10-25 13:33:25 UTC      

Page Views: 9 views

7.2.1. Basic introduction

Django is an open source Web application framework written by Python.

Using Django, Python programmers can easily complete most of the content needed by a formal website with very little code, and further develop a full-function Web service Django itself based on MVC model, that is, Model (model) + View (view) + Controller (controller) design pattern. MVC pattern simplifies subsequent modifications and extensions of the program, and makes it possible to reuse a certain part of the program.

MVC advantages:

  • Low coupling

  • Quick development

  • Easy to deploy

  • High reusability

  • Low maintenance cost

Python plus Django is the best combination for rapid development, design and deployment of websites.

7.2.2. Characteristics

  • Powerful database function

  • Comes with powerful background functions.

  • Elegant web site

7.2.3. MVC and MTV model

7.2.4. MVC model

MVC pattern (Model-view-controller) is a software architecture pattern in software engineering, which divides the software system into three basic parts: Model, View and Controller.

MVC are connected together in a plug-in, loosely coupled manner.

  • Model (M)-the function of writing a program, which is responsible for mapping business objects to databases (ORM).

  • View (V)-graphical interface, responsible for interaction with the user (page).

  • Controller (C)-responsible for forwarding requests and processing requests.

Simple figure:

image0

User operation flow chart:

image1

7.2.5. MTV model

The MTV mode of Django is essentially the same as that of MVC, and it is also for the purpose of maintaining a loosely coupled relationship between components, except that the definition is slightly different. The MTV of Django refers to:

  • M representation model (Model): the function of writing a program, which is responsible for mapping business objects to databases (ORM).

  • T represents template (Template): responsible for how to display the page (html) to the user.

  • V represents the view (View): responsible for the business logic and calling Model and Template when appropriate.

In addition to the above three layers, you also need a URL dispatcher, which is used to distribute URL page requests to different View processing. The response mode of View calling the corresponding Model and Template,MTV is as follows:

Simple figure:

image2

User operation flow chart:

image3

解析:

The user initiates a request (request) to our server through the browser, which accesses the view function:

  • a.如果不涉及到数据调用,那么这个时候视图函数直接返回一个模板也就是一个网页给用户。

  • b.如果涉及到数据调用,那么视图函数调用模型,模型去数据库查找数据,然后逐级返回。

The view function fills the returned data into the spaces in the template and finally returns the web page to the user.

Reference address:

[1] Https://www.cnblogs.com/liuhui0308/p/12189658.html

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。