您如何将您的项目分为Django中的应用程序? [英] How do you divide your project into applications in Django?

查看:106
本文介绍了您如何将您的项目分为Django中的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定如何将Django项目分解为应用程序。

I am not really sure how to divide my Django projects into applications.

布局Django项目时需要考虑什么?

What things should I consider when laying out a Django project?

推荐答案

詹姆斯·班内特(James Bennett)写了一篇关于这个的博文,

James Bennett has written a blog entry about this,

Django提示:布局应用程序,项目与应用程序:


应用程序尝试提供一个相对独立的单个相关功能集。允许应用程序定义一组模型(虽然它不必),并定义和注册自定义模板标记和过滤器(尽管如此,它不必)。

An application tries to provide a single, relatively self-contained set of related functions. An application is allowed to define a set of models (though it doesn’t have to) and to define and register custom template tags and filters (though, again, it doesn’t have to).

项目是一个应用程序的集合,安装在同一个数据库中,并且都使用相同的设置文件。在某种意义上,项目的定义方面是提供一个设置文件,该文件指定要使用的数据库,要安装的应用程序和其他配置位。一个项目可能对应一个单一的网站,但不一定要 - 多个项目可以在同一个站点上运行。该项目还负责根URL配置,尽管在大多数情况下,只需将呼叫包含在各个应用程序中的URL配置中即可。

A project is a collection of applications, installed into the same database, and all using the same settings file. In a sense, the defining aspect of a project is that it supplies a settings file which specifies the database to use, the applications to install, and other bits of configuration. A project may correspond to a single web site, but doesn’t have to — multiple projects can run on the same site. The project is also responsible for the root URL configuration, though in most cases it’s useful to just have that consist of calls to include which pull in URL configurations from individual applications.

这篇关于您如何将您的项目分为Django中的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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