Django与模型视图控制器 [英] Django vs. Model View Controller

查看:94
本文介绍了Django与模型视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释一下Django和Model View Controller模式之间的不同之处吗?



功能上,我们可以从这些差异中获得什么,例如,Ruby on Rails?

解决方案

当你编码时,不考虑框架片的名称,没有可疑的差异,例如RoR。但是,这取决于你使用模型,因为在Django上,他们很容易包含一些逻辑,其他框架将保持在控制器级别。



Django上的视图往往是一组用于获取数据的查询,并将其传递给模板。


Can somebody explain me where the diferences are between Django and the Model View Controller pattern?

Functionally, what can we expect from those differences — i.e. what works differently comparing Django to, for example, Ruby on Rails?

解决方案

When you code, not thinking about names of framework pieces, there are no susbtantive differences betw, for example RoR. But it depends on the use you give models, since on Django they easily contain some logic that on other frameworks would stay at controller level.

The view on Django tends to be a set of queries for fetching data, and pass them to the template.

这篇关于Django与模型视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆