MVC和django基础 [英] MVC and django fundamentals

查看:94
本文介绍了MVC和django基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个场景很新鲜,试图找到一些文档来采用最佳做法。我们正在建立一个相当大的内容网站,它将由各种媒体目录组成,我正在寻找一些可比较的数据/架构模型,以便我们更好地了解我们应该使用的框架,我们从未以前使用过。任何见解/帮助将不胜感激!

Pretty new to this scene and trying to find some documentation to adopt best practices. We're building a fairly large content site which will consist of various media catalogs and I'm trying to find some comparable data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before. Any insight / help would be greatly appreciated!

推荐答案

数据/建筑模型,以便我们可以更好地了解方法我们应该使用我们从未使用的框架。

"data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before"

Django对您施加最佳做法。你没有太多的选择,不能犯很多错误。

Django imposes best practices on you. You don't have a lot of choices and can't make a lot of mistakes.

MVC(虽然高贵的愿望)实现如下:

MVC (while a noble aspiration) is implemented as follows:


  • 使用Django ORM模型在models.py文件中定义数据。

  • urls.py文件映射URL查看功能。

  • 查看功能执行所有处理,利用模型中的模型和方法

  • 由View调用的演示文稿(通过HTML模板)功能。基本上没有处理可以在演示中进行,只是轻量级的迭代和决策。

  • Data is defined in "models.py" files using the Django ORM models.
  • urls.py file maps URL to view function. Pick your URL's wisely.
  • View function does all processing, making use of models and methods in models
  • Presentation (via HTML templates) invoked by View function. Essentially no processing can be done in presentation, just lightweight iteration and decision-making

模型是为您定义的。只要坚持Django自然而然,你会很开心。

The model is defined for you. Just stick to what Django does naturally and you'll be happy.

在建筑上,你通常有这样的堆栈。

Architecturally, you usually have a stack like this.


  • Apache做了两件事。

  • Apache does two things.


  • 直接和立即提供静态内容

  • 将动态URL传递给Django(通过mod_python,mod_wsgi或mod_fastcgi)。 Django应用程序映射URL以查看功能(通过ORM /模型访问数据库)并通过模板显示。

数据库由Django查看功能使用

Database used by Django view functions.

该架构是为您定义的,只需坚持Django自然而然地你会很高兴。

The architecture is well-defined for you. Just stick to what Django does naturally and you'll be happy.

随意阅读 Django文档,很好,也许是最好的。

Feel free to read the Django documentation. It's excellent; perhaps the best there is.

这篇关于MVC和django基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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