Django的MPTT是什么?
Django的MPTT是一个可重用/独立Django应用程序,目的是让您轻松地使用自己的Django的在自己的应用程序的模型先根遍历树。
It takes care of the details of managing a database table as a tree structure and provides tools for working with trees of model instances.
它利用管理作为一个树状结构数据库表中的细节,并提供与模型实例树木的工作工具。
功能概述
Simple registration of Django model classes for MPTT - fields required specifically for the tree structure will be added dynamically if necessary.简单的注册Django的模型类的MPTT -所需具体领域的树状结构将被动态如有必要。
In the simplest case, it's possible to use MPTT with your own models without adding a single line of MPTT-related code to them.在简单的情况下,它可以使用自己的模型,而不加入的MPTT单行相关的代码它们MPTT。
The tree structure is automatically managed when you create or delete MPTT model instances.树结构管理,自动当您创建或删除MPTT模型的实例。 By default, new instances are added as the last child of their parent if they have one, otherwise they become the root of a new tree.默认情况下,新的实例被添加作为父母,如果他们最后一个孩子有一个,否则他们成为新树的根。
The tree structure is automatically updated when you change a model instance's parent - by default, modified instances are moved so they are the last child of their new parent.树结构自动更新当您更改模型实例的母公司-默认情况下,修改实例所以他们提出了他们的新父母的最后一个子。
This allows basic management of the tree using the parent field available to you in the django.contrib.admin application and in newforms forms generated using the ModelForm class.这允许使用外地的家长,可以在django.contrib.admin申请你和newforms形式产生的使用ModelForm类树的基本管理。
To override the defaults insertion/reparenting positions mentioned above, you can specify that a particular field in your model is used for ordering when inserting or automatically reparenting model instances.要覆盖默认插入/上述抚育位置,您可以指定一个特定领域模型是购买时插入或自动抚育模型的实例使用。
This allows you to have each level of the tree automatically sorted by a field of your choice.这使您可以自动地使每一个由您选择的字段进行排序树的水平。
New methods are added model classes which are registered with MTTP, for changing their position in the tree, retrieving their ancestors, siblings and descendants, determining the number of descendants they have and other tree-related operations.添加新的方法对改变其位置在树模型与MTTP登记类,检索他们的祖先,兄弟姐妹和后代,确定它们的后代和其他相关的操作树号码。
A custom TreeManager manager is added to all MPTT model classes, providing tree management operations which, among other things, can be used to move any node in a tree (and its descendants) to an arbitrary point elsewhere in the tree, or to insert new nodes at any point in the tree.自定义TreeManager经理添加到所有MPTT模型类,提供树木管理,除其他外,可用于移动任何一树(及其后代)中的任意一个其他地方的树,节点或插入新的行动在任何节点树点。
newforms components for working with trees in forms.表单中的树木工作newforms组件。
Utility functions for working with trees of models.模型与树木的工作实用功能。
Template tags and filters for working with trees of models in templates.模板标记并与树木的工作模式过滤模板。
![](http://img.zemanta.com/pixy.gif?x-id=f1e07fd7-58a6-89d6-9596-bd504feba6a6)